What shall I return if there are multiple max/min value keys


  • -1
    R

    What shall I return if there are multiple max/min value keys


  • 0

    The problem statement mentions return one of the keys, so any max/min keys returned will be judged as correct.


  • 0
    J

    Input:
    ["AllOne","inc","inc","inc","inc","inc","dec","getMaxKey","getMinKey","inc","inc","inc","getMaxKey","getMinKey","inc","inc","getMinKey"]
    [[],["hello"],["hello"],["world"],["world"],["hello"],["world"],[],[],["world"],["world"],["leet"],[],[],["leet"],["leet"],[]]
    Output:
    [null,null,null,null,null,null,null,"hello","hello",null,null,null,"world","leet",null,null,"leet"]
    Expected:
    [null,null,null,null,null,null,null,"hello","world",null,null,null,"world","leet",null,null,"world"]
    But why 'leet' is wrong? 'hello', 'world', 'leet' all appeared 3 times, but why only expect world?


  • 1

    @jifengzhilong In the first getMinKey(), it should return "world", but your output returns "hello".


  • 0
    J

    Oh, I missed it, thanks.


Log in to reply
 

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