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
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 5ms, memory 17.4MB, accepted 2026-01-01.
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