Click here to see the full article post
@dxy_1993 Probably a copy&paste error, the "Size of recursion tree can go upto n" doesn't make much sense here :-)
@dxy_1993 @ StefanPochmann I have updated it. Thanks.
I doubt the space complexity O(1) for the sorting solution. I'd expect at least logarithmic space usage. And a quick look at the source suggests that it even takes linear space (though I didn't read it all).
(edit: fixed typo "linear time" to "linear space")
Approach 4 may be optimized by set a termination condition when putting the new element into the Hashset.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.