Largest Adjacent Difference (Set 12)

Easy

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

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

Example 1

maxAdjacentDifference()
Input
nums = [42, 7, -8, -38, -20, -26, -7, -27, 12, 30, 27, 21, 49, 15, 2, -36, 30, -1, 46, 48, 6, 28, -21, 18, 13, 36, -40, -13, 41, -24, 10, -34, 22, 21, 27, -9, -17, 45, 31, 24, -22, 31, 33, 21, 41, -25]
Output
76

Why

`maxAdjacentDifference` returns `76` for this input.

Example 2

maxAdjacentDifference()
Input
nums = [-30, 18, 13, -13, -39, -4, 44, 2, -9, -35, -38, -30, -36, 49, -12, 27, 13, -37, 45, -12, 33, 18, -24, -34, -4, -9, 50, -25, -12, -24, -40, 8, -29, 42, 15, -14, -32, 30, -33, -28, 44, -39, 0, -35, 25, 14, 47]
Output
85

Why

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