Add Bold Tag in a String

  • 0

    Click here to see the full article post

  • 0

    I have a question about the runtime of Approach#2: will the line of sorting "Collections.sort(list, (a, b) -> a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]);" 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)) ?

  • 0

    The complexity analysis for method#2 is incorrect. We also need to factor in the runtime for sorting.

  • 0

    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!

  • 0

    Where exactly is the second solution? I don't see it now. Is there anything better than brute force?

  • 0

    why break the outerloop

Log in to reply

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