LeetCode solutions

3747. Maximum Difference Between Adjacent Elements in a Circular Array

My accepted Python solution to LeetCode problem 3747, Maximum Difference Between Adjacent Elements in a Circular Array, running in 5ms.

  • Difficulty: Easy
  • Python
  • Runtime 5ms
  • Memory 17.4MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 5ms, memory 17.4MB, accepted 2026-01-01.

python
class Solution:
    def maxAdjacentDistance(self, nums: List[int]) -> int:
        n = len(nums)
        max_diff = 0
        for i in range(n):
            diff = abs(nums[i] - nums[(i + 1) % n])
            max_diff = max(max_diff, diff)
        return max_diff

Source