Largest Adjacent Difference (Set 1)

Easy

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

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

Example 1

maxAdjacentDifference()
Input
nums = [50, 23, 30]
Output
27

Why

`maxAdjacentDifference` returns `27` for this input.

Example 2

maxAdjacentDifference()
Input
nums = [-8, -6, 18, 38, -23]
Output
61

Why

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