Click here to see the full article post
I have a question about the runtime of Approach#2: will the line of sorting "Collections.sort(list, (a, b) -> a == b ? a - b : a - b);" be the dominant part of run time?
Since in the worst case the list size is O(s∗l), I guess sorting can take O(sllog(s*l)) ?
The complexity analysis for method#2 is incorrect. We also need to factor in the runtime for sorting.
Can you please explain more on time complexity analysis? The 1st method I thought it is s^2; 2nd solution where does the x come from? I thought it is O(ls). Thanks!
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.