Largest Adjacent Difference (Set 7)

Easy

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

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

Example 1

maxAdjacentDifference()
Input
nums = [44, 50, 25, -7, 15, 10, -36, -26, -14, 19, -11, 5, 26, 30, 43, -37, 43, 19, 21, 18, 15, -12, 24, 11, -9, 12, -33]
Output
80

Why

`maxAdjacentDifference` returns `80` for this input.

Example 2

maxAdjacentDifference()
Input
nums = [45, -13, 46, -12, 14, -8, 11, 47, -36, 16, 20, -18, 27, -27, -4, -22, -22, -2, -21, 26, 29, 41, 42, 4, 15, -14, 41, -38, 45, -6]
Output
83

Why

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