Skip to content

Commit 8dedec0

Browse files
committed
Add leetcode problem 3423
1 parent 4c05cd2 commit 8dedec0

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

leetcode/src/03423_maximum_difference_between_adjacent_elements_in_a_circular_array/__init__.py

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from typing import List
2+
from itertools import pairwise
3+
4+
5+
class Solution:
6+
def maxAdjacentDistance(self, nums: List[int]) -> int:
7+
return max(abs(nums[0] - nums[-1]), max(abs(x - y) for x, y in pairwise(nums)))
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import unittest
2+
from .solution import Solution
3+
4+
5+
class TestSolution(unittest.TestCase):
6+
def test_maxAdjacentDistance(self):
7+
s = Solution()
8+
self.assertEqual(s.maxAdjacentDistance([1, 2, 4]), 3)
9+
self.assertEqual(s.maxAdjacentDistance([-5, -10, -5]), 5)
10+
11+
12+
if __name__ == "__main__":
13+
unittest.main()

0 commit comments

Comments
 (0)