Question about a test case


  • 0
    F

    Hey guys, I got stuck by a test case:

    [24,46,1,75,0,15,51,82,51,5,80,31,13,80,92,61,4,91,68,4,25,82,70,60,12,31,21,17,15,92,9,61,55,65,95,19,3,6,30,4,40,73,40,28,69,35,59,84,44,94,83,62,66,41,66,12,32,64,63,36,46,68,86,84,81,30,39,89,51,39,15,16,76,23,89,62,33,95,34,63,95,90,45,92,83,20,40,80,48,54,17,48,90,77,42,43,36,76,97]
    91
    

    My output is [1,37,99]
    But the expected answer is [1,5,37,99]

    Both solution have the same cost because arr[5] == 0, and [1,37,99] is lexicographic smaller than [1,5,37,99].

    Can someone explain why the expected answer is [1,5,37,99]? Thanks!


  • 0
    F

    Okay... I mis-understood the definition of the lexicographically smaller.

    Path Pa1, Pa2, ..., Pan is lexicographically smaller than Pb1, Pb2, ..., Pbm, if and only if at the first i where Pai and Pbi differ, Pai < Pbi; when no such i exists, then n < m.
    

    Can someone help me delete this post? Thanks


Log in to reply
 

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