Largest Adjacent Difference (Set 4)

Easy

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

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

Example 1

maxAdjacentDifference()
Input
nums = [37, 7, -22, -16, -34, -34, 26, -28, -1, 50, 19, 44, -9, -19, -23, -12, 15, 50, 29, 34]
Output
60

Why

`maxAdjacentDifference` returns `60` for this input.

Example 2

maxAdjacentDifference()
Input
nums = [14, 4, -16, 38, 6, 12, 32, 31, -7, -25, -37, -33, -7, -16, -31, -32, -33, 47, -12, -24, 6, 1]
Output
80

Why

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