Largest Adjacent Difference (Set 9)

Easy

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

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

Example 1

maxAdjacentDifference()
Input
nums = [25, -12, 31, -7, 8, 48, 2, 19, -38, 16, 42, 50, 15, 4, 9, -13, 16, 18, 10, 36, 37, -27, -1, 16, -1, -3, 20, 47, 36, -38, -17, -13, 30, 19, -40, -14, -30, -3, -11, 34, 41, -12, -31, 27, 33, 34]
Output
74

Why

`maxAdjacentDifference` returns `74` for this input.

Example 2

maxAdjacentDifference()
Input
nums = [29, 11, 34, 21, 22, -15, -38, -35, -30, -22, -26, 32, 38, 31, -9, 38, 22, 5, -22, -12, 45, 15, -17, 10, 38, 37, -3, -4, 3, 17, -2, -3, -20, -10, 31, -29, 8, -38, 23, 30, 10, 28, 19, -22, 7, -5, -35]
Output
61

Why

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