Question about a test case

  • 0

    Hey guys, I got stuck by a test case:


    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

    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.