No. There is a test case which is unsorted. I implemented a quick sort.
Does anyone have a better solution without sorting the input?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.