Clarification of the problem

  • 0

    In the following input::
    My Output:

    I did not understand why the expected is 3. Because, the maximum gap in sorted form is 9 -3 = 6. May be my understanding is wrong. Can anybody please explain the problem with example?

  • 0
    This post is deleted!

  • 1

    Sorted, the array is [1,3,6,9]. There's no gap from 3 to 9 because there's the 6 between them. And if you ignore that, why don't you also ignore the 3 and think the biggest gap is 9-1=8?

  • 0

    Thanks StefanPochmann. Initially, i thought that the problem is to find the maximum gap in the unsorted array. Since, 1 comes after 9, so, it should not be counted since it is not in the sorted form inside the unsroted array. Anyway, now I understand the problem.

Log in to reply

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