Largest Adjacent Difference (Set 2)

Easy

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

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

Example 1

maxAdjacentDifference()
Input
nums = [-11, -10, -17, 12, 5, -38, -8, -8, -8, 42, 40, -17, 1, -9]
Output
57

Why

`maxAdjacentDifference` returns `57` for this input.

Example 2

maxAdjacentDifference()
Input
nums = [46, 17, -1, -19, 8, 18, 17, 18, -7, -40, 38, -38]
Output
78

Why

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