Sorting dictionary is not optimal!


  • 0
    Y

    The time complexity is O(n log n) to sort the dictionary, given a dictionary with n strings.

    However, if we give the dictionary a single pass checking every string and record the longest string so far, it's only O(n).


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.