Largest Adjacent Difference (Set 14)

Easy

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

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

Example 1

maxAdjacentDifference()
Input
nums = [33, -36, -32, 19, -13, -2, -2, -32, 8, 34, -11, 48, -8, 3, -14, -6, -11, 2, -35, -1, 6, 32, -26, 41, 16, 33, 47, 11, -5, -27, -7, -36, 32, -17, -13, 32, 4, 30, -17, 15, -8, 50, 48, 15, -14, 9, -31, -39]
Output
69

Why

`maxAdjacentDifference` returns `69` for this input.

Example 2

maxAdjacentDifference()
Input
nums = [50, 0, 28, -36, -28, 10, 10, 24, -1, -28, -29, 50, -32, -15, -22, 17, -37, -11, 24, -40, -38, 15, -15, 45, 17, 12, 9, 19, 13, 46, 8, -24, -22, -35, -33, -22, 7, 34, 2, -31, 47, 17, -7, -29, 0, 21, 39, -24]
Output
82

Why

`maxAdjacentDifference` returns `82` 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.