3423. Maximum Difference Between Adjacent Elements in a Circular Array

Tapan RachchhTapan Rachchh
1 min read
class Solution:
    def maxAdjacentDistance(self, nums: List[int]) -> int:
        nums = [nums[-1]] + nums

        maxDiff = 0
        for i in range(len(nums) - 1):
            a = nums[i]
            b = nums[i + 1]

            diff = abs(a - b)
            maxDiff = max(diff, maxDiff)


        return maxDiff
0
Subscribe to my newsletter

Read articles from Tapan Rachchh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tapan Rachchh
Tapan Rachchh