Algorithm · Waymo · Hard
You are given an integer array nums in arbitrary order. Imagine arranging its elements in nondecreasing order, then find the largest difference between two adjacent elements in that sorted arrangement. If nums contains fewer than two elements, return 0, since there is no adjacent pair to compare. The algorithm must run in $$O(n)$$ time and use $$O(n)$$ extra space. A comparison-based sorting algorithm is not permitted. Example 1: Explanation: After arranging the values in…
Checking your access…