Largest Adjacent Difference (Set 13)

Easy

Given an array of at least two integers nums, return the largest absolute difference between two neighbouring values.

Largest Adjacent Difference (Set 13) — the data. This set runs 4 cases: nums holds arrays of 48–48 items, with values from -40 to 49. The hidden cases are the largest of the set.

Example 1

maxAdjacentDifference()
Input
nums = [-32, -25, 3, 42, 33, -24, -16, 37, 39, 3, 21, 22, 24, -12, 27, -8, -23, -6, 36, 9, 7, -8, 20, 43, -4, 38, -17, -28, 47, -26, 17, -17, -18, -23, 30, 14, 1, 14, 3, 25, 17, -10, 26, -1, 3, -4, 24, -34]
Output
75

Why

`maxAdjacentDifference` returns `75` for this input.

Example 2

maxAdjacentDifference()
Input
nums = [46, -34, 19, -23, -4, 49, -38, 5, -11, -9, 46, -6, 4, -25, -37, -12, 8, 37, -37, 38, -4, 14, 31, 32, 9, -31, 23, 26, 19, -29, 30, -25, 16, -26, -24, 0, -7, 21, -23, 36, 5, -40, 37, 29, -8, 8, 39, 11]
Output
87

Why

`maxAdjacentDifference` returns `87` for this input.
Constraints
2 <= nums.length <= 10^5
-10^4 <= nums[i] <= 10^4
Every case in this set must pass: the first two are visible on Run, the last two unlock on Submit.

Topics

Arrays

Implement maxAdjacentDifference in the editor and return the answer — printing it is never graded.