I want to know the time complexity of ''.join(sorted(a)) when done twice on 2 strings.
Asked
Active
Viewed 272 times
0
-
`sorted()` on its own `O(nlogn)` , see here for join https://stackoverflow.com/a/34008289/2308683 – OneCricketeer Apr 12 '21 at 04:18
-
On two strings, `sorted` takes time at most proportional to the length of the shorter string, in order to do a lexicographic comparison. It's not clear what you mean by "done twice" though; after you've done it once, there is only one string. – kaya3 Apr 13 '21 at 06:06