Modified question: find the mimimum difference instead of the maximum difference?

  • 0

    Change to "Given an unsorted array, find the MINIMUM difference between the successive elements in its sorted form."
    Is there any linear algorithm for above problem?

  • 0

    Yes if you believe radix sort is linear. I couldn't think of an algorithm similar to what's presented in the solution (i.e. bucket sort), but maybe someone can come up with one.

Log in to reply

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