|
| 1 | +<h2><a href="https://leetcode.com/problems/maximum-difference-between-adjacent-elements-in-a-circular-array/?envType=daily-question&envId=2025年06月12日">3423. Maximum Difference Between Adjacent Elements in a Circular Array</a></h2><h3>Easy</h3><hr><p>Given a <strong>circular</strong> array <code>nums</code>, find the <b>maximum</b> absolute difference between adjacent elements.</p> |
| 2 | + |
| 3 | +<p><strong>Note</strong>: In a circular array, the first and last elements are adjacent.</p> |
| 4 | + |
| 5 | +<p> </p> |
| 6 | +<p><strong class="example">Example 1:</strong></p> |
| 7 | + |
| 8 | +<div class="example-block"> |
| 9 | +<p><strong>Input:</strong> <span class="example-io">nums = [1,2,4]</span></p> |
| 10 | + |
| 11 | +<p><strong>Output:</strong> <span class="example-io">3</span></p> |
| 12 | + |
| 13 | +<p><strong>Explanation:</strong></p> |
| 14 | + |
| 15 | +<p>Because <code>nums</code> is circular, <code>nums[0]</code> and <code>nums[2]</code> are adjacent. They have the maximum absolute difference of <code>|4 - 1| = 3</code>.</p> |
| 16 | +</div> |
| 17 | + |
| 18 | +<p><strong class="example">Example 2:</strong></p> |
| 19 | + |
| 20 | +<div class="example-block"> |
| 21 | +<p><strong>Input:</strong> <span class="example-io">nums = [-5,-10,-5]</span></p> |
| 22 | + |
| 23 | +<p><strong>Output:</strong> <span class="example-io">5</span></p> |
| 24 | + |
| 25 | +<p><strong>Explanation:</strong></p> |
| 26 | + |
| 27 | +<p>The adjacent elements <code>nums[0]</code> and <code>nums[1]</code> have the maximum absolute difference of <code>|-5 - (-10)| = 5</code>.</p> |
| 28 | +</div> |
| 29 | + |
| 30 | +<p> </p> |
| 31 | +<p><strong>Constraints:</strong></p> |
| 32 | + |
| 33 | +<ul> |
| 34 | + <li><code>2 <= nums.length <= 100</code></li> |
| 35 | + <li><code>-100 <= nums[i] <= 100</code></li> |
| 36 | +</ul> |
0 commit comments