the worst case of QuickSort is O(n2)
So I use the randomized QuickSort to avoid the worst case, but I still be "Time limited exceed"?
I fail to pass a test case where there're lots of duplicate. I guess you might run into the same problem here.
Say if the list is "1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1", and each time all the 1s will still be on one of the left or right list, depended on how you are dealing with the case of duplicates.
I think if you randomize the placement of duplicates, you could pass the test case.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.