Largest Adjacent Difference (Set 10)

Easy

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

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

Example 1

maxAdjacentDifference()
Input
nums = [-33, 31, -8, -39, 14, -29, -14, -2, -30, -13, -12, -19, 39, 15, 13, -39, -29, -13, 42, 37, -14, 16, -12, 20, 9, 45, 29, -20, -2, 29, -25, -23, 23, 26, 32, 23, 29, 40]
Output
64

Why

`maxAdjacentDifference` returns `64` for this input.

Example 2

maxAdjacentDifference()
Input
nums = [-40, -32, 12, 15, 20, 49, 14, -10, 1, 37, 11, 37, -31, 7, -16, 32, 22, 22, 8, -3, 50, -6, -33, -7, -31, 50, -6, 25, -4, 2, 19, 27, 43, 4, -9, 48, 21, -40, 37, 35, 42, -34, -14, -19, 33, 31, -37, 22]
Output
81

Why

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