Ctrl K

Biggest Gap at a Round Table

Easy
Players sit around a round table, each with a score. The array scores lists them in seating order: scores[i] sits next to scores[i + 1], and the last player sits next to the first. Return the largest absolute difference between the scores of two neighbours.
Example 1
scores=[3, 8, 6, -2] → 8

The neighbouring pairs are 3 and 8, 8 and 6, 6 and -2, and also -2 and 3 since the table is round. The biggest gap is |6 - (-2)| = 8.

Example 2
scores=[10, 4, 1, 25] → 24

The last and first players sit side by side: |25 - 10| = 15, but 1 and 25 are neighbours too, with a gap of 24.

Example 3
scores=[-5, -5] → 0
Constraints
  • 2 ≤ len(scores) ≤ 100
  • -100 ≤ scores[i] ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsPair With a Target Sum EasySqueeze Repeats Out of a Sorted Array EasyDrop the Unwanted Value EasySlot on a Sorted Shelf EasyAdd One to a Digit Array Easy
loading Python…
Input
scores=[3, 8, 6, -2]
Expected
8

Run checks the first 3 tests in your browser. Submit checks all 119 tests on the server, hidden ones included.