Not ideal for bubble sort, might be a DP problem


  • 0
    B

    I used bubble sort and because it is O(n^2) complexity, it gave me a timeout the first time and the second time, it accepted my solution. But it's supposed to be faster with merge sort.

    My question is, this looks like a dynamic programming problem. But I don't know how to implement it. Has anyone got any idea? Thanks in advance.


  • 0
    B

    Look up Dutch National Flag problem on wiki. It has a linear runtime solution.


Log in to reply
 

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