LeetCode Weekly Contest 32
@1337c0d3r thanks :D
Excellent logic. It is much easier to visualize after reading your text. Thank a lot.
No one has replied
@shawngao Thanks for the clear solution! One small improvement, we only need to track indices, instead of the actual Points. Here's the C++ version:
This is one of the kind of algorithms that appears simple on first sight but are actually ingenuity in disguise.
@shawngao test fails for input [1,2,3,4]
for that need to add extra condition as if(start==end)return 0;
@i_square I appreciate you idea, and I think it is the best.
@alexander The first solution is easy to think of. And the second solution is awesome to solve problem in O(n) space and O(n) time. Thank you for your post!
Use %2 to save space:
shorter writing style for same algorithm
@zestypanda I think a parent process might have multiple children, so an unordered_set is necessary. I didn't check the test case though.
Disabled Categories are greyed out
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.