Largest Adjacent Difference (Set 11)

Easy

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

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

Example 1

maxAdjacentDifference()
Input
nums = [-3, -3, -28, -39, -22, 6, 47, 34, 25, 12, 4, 49, 36, 43, 43, 17, -2, -22, 11, -29, 50, -21, -5, 29, 49, 18, -4, -7, 28, -2, 24, -36, -18, 8, 1, 14, -4, -29, 25, 4, 15, -34, -4, 6, 41, 30, 20, -17]
Output
79

Why

`maxAdjacentDifference` returns `79` for this input.

Example 2

maxAdjacentDifference()
Input
nums = [8, 13, 16, 33, -15, -34, -17, -4, 38, 20, 18, -24, -8, 10, -25, 35, -4, 5, 1, 13, 36, -25, -39, -32, 18, 37, -1, 46, 26, -33, 6, 38, -9, 0, 28, 1, 47, -27, 28, -1, -24, -23, -38]
Output
74

Why

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