3423. Maximum Difference Between Adjacent Elements in a Circular Array Easy

@problem@discussion
#Array



1/**
2 * [3423] Maximum Difference Between Adjacent Elements in a Circular Array
3 *
4 * Given a circular array nums, find the maximum absolute difference between adjacent elements.
5 * Note: In a circular array, the first and last elements are adjacent.
6 *  
7 * <strong class="example">Example 1:
8 * <div class="example-block">
9 * Input: <span class="example-io">nums = [1,2,4]</span>
10 * Output: <span class="example-io">3</span>
11 * Explanation:
12 * Because nums is circular, nums[0] and nums[2] are adjacent. They have the maximum absolute difference of |4 - 1| = 3.
13 * </div>
14 * <strong class="example">Example 2:
15 * <div class="example-block">
16 * Input: <span class="example-io">nums = [-5,-10,-5]</span>
17 * Output: <span class="example-io">5</span>
18 * Explanation:
19 * The adjacent elements nums[0] and nums[1] have the maximum absolute difference of |-5 - (-10)| = 5.
20 * </div>
21 *  
22 * Constraints:
23 * 
24 * 	2 <= nums.length <= 100
25 * 	-100 <= nums[i] <= 100
26 * 
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/maximum-difference-between-adjacent-elements-in-a-circular-array/
31// discuss: https://leetcode.com/problems/maximum-difference-between-adjacent-elements-in-a-circular-array/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36    pub fn max_adjacent_distance(nums: Vec<i32>) -> i32 {
37        0
38    }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45    use super::*;
46
47    #[test]
48    fn test_3423() {
49    }
50}
51


Back
© 2025 bowen.ge All Rights Reserved.