Largest Adjacent Difference (Set 5)

Easy

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

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

Example 1

maxAdjacentDifference()
Input
nums = [17, 11, -4, -27, -4, 12, 11, 38, -11, 4, 44, 36, 7, 48, 46, 24, 32, -11, 22, 40, -36, -31, -18, 46, 29, 10, 22, 13, 19, 18, 42, -6, 42, 5, 1, -18, 44, 40]
Output
76

Why

`maxAdjacentDifference` returns `76` for this input.

Example 2

maxAdjacentDifference()
Input
nums = [-3, -35, 50, 45, -28, 2, 6, -22, -31, -28, 38, -1, -10, 2, -17, 11, 16, -22, -24, -23, 27, 47]
Output
85

Why

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