Click here to see the full article post
@ruiixu23 Both the Java and Python3 solutions return
[2,4], so they seem correct to me. Next time, you can check this yourself by pasting the editorial solutions into the submission box and using the "Custom Testcase" option.
Sorry. Overlooked that you set (line 6 of Java code)
nums.length, which doesn't correspond to what the animation is showing. I was assuming using
nums.length - 1 to initialize
hi. In that case, it will be wrong and I hope you agree with me.
@ruiixu23 Ah, fair enough. I can see how that might be a tad confusing; exclusive vs. inclusive ends of ranges. :) I apologize for snapping at you.
STL comes to rescue here, Use C++ inbuilt function equal_range().
One line of code :)
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.