Largest Adjacent Difference (Set 8)

Easy

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

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

Example 1

maxAdjacentDifference()
Input
nums = [-36, 6, 31, -40, 4, -2, 16, -2, -25, 35, -2, 16, 36, -25, -22, -25, -29, 2, 44, -23, 37, -28, -32, 20, 13, -1, -6, -9, 41, 22, -36, -24, -14, 42, 18, 42, -1, 4, -4, 5, 13, 34]
Output
71

Why

`maxAdjacentDifference` returns `71` for this input.

Example 2

maxAdjacentDifference()
Input
nums = [37, -26, 43, 13, 25, -32, 28, 5, -30, -17, -18, -26, 1, 32, -1, -15, 45, -5, -32, 23, 46, 4, 6, 41, 7, -25, 45, -15, -3, -9, 9, -5, 47, -21, 30, 27, -9, 25, -24, 38, 2, 16, 20, -16, -10, -19]
Output
70

Why

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