#Is there iterator that applies custom binary operation?

1 messages · Page 1 of 1 (latest)

cloud summitBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

covert crypt
#

Could you explain how your current solution roughly works? I am having a hard time figuring out whether it's O(n) or O(n^2) with the use of high-level templated code. I understand what the C++ functions do on an individual level. It looks like you're trying to basically do this C-like solution of iterating forwards once and backwards once? Neither your nor this solution does the follow up challenge of using O(1) space, though:
https://leetcode.com/problems/product-of-array-except-self/solutions/4990895/c-prefix-and-postfix/

#

lol, I like how the Solutions tab of that leetcode question is full of people who ignored the "without using division" part of the exercise.

covert crypt
#

I've set that godbolt page up to use the flags mentioned here, for both the execution and compiler windows

covert crypt
#

(throwing the generated Assembly from both programs on godbolt into text files, and diffing them shows they're pretty much identical, both with and without fsanitize)

#

Okay yeah, your solution is completely fine, it's apparently just that the people behind leetcode don't know shit about how to properly time your code (or are just greedy), cause it seems like they repeat their tests so few times that my percentage fluctuates this much when I resubmit that exact same C-like solution from that person I linked

covert crypt
#

Thanks, I got it after a few hours :)

cloud summitBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity