Questions about multiple valid answers


  • 1
    H

    Hey,

    For the example:
    [[7,0],[4,4],[7,1],[5,0],[6,1],[5,2]]
    is
    [[7,0],[5,0],[6,1],[7,1],[5,2],[4,4]]

    not a valid Queue order? It seems to follow all the rules and restrictions, unless I'm missing something.

    Thanks


  • 0
    F

    [4,4] obviously disobey the rule.


  • 0
    P

    I agree with you. It seems to me like the solutions to this problem are not unique. What you pasted seems like it obeys the rules outlined in the problem. Could someone explain why solutions are unique?


  • 0
    P

    @fsi206914 Can you explain why [4, 4] disobeys the rule?

    To quote the problem: k is the number of people in front of this person who have a height greater than or equal to h. In the above example k = 4; h = 4 and there are 5 people ahead of [4, 4] with heights greater than or equal to 4. Since 5 > 4 the requirement is satisfied.


Log in to reply
 

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