Is the example wrong? Am I missing something?


  • 2
    P

    "For example,

    Given 1->4->3->2->5->2 and x = 3,

    return 1->2->2->4->3->5."

    In the return, why does 4 come before 3 if it's larger???

    Also, my code fails this test:
    "Input: {2,1}, 1

    Output: {1,2}

    Expected: {2,1}"

    If x is 1, why would the expected output have 2 come before 1?

    Thanks.


  • 9
    M

    you should partition the list but you should not change the order in each partition. In the first example:
    1, 2, 2 are smaller than 3 and 4,3,5 are greater or equal than 3 but notice that their order is same is in the original list.
    In the second example, there is not node less than 1 and 2,1 are greater or equal to 1 with same order as original list.


Log in to reply
 

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