Given a circular array nums, find the maximum absolute difference between adjacent elements.
Note: In a circular array, the first and last elements are adjacent.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
package main
import"math"
funcmaxAdjacentDistance(nums []int)int { res := 0 n := len(nums) for i := 0; i < n; i++ { res = max(res, int(math.Abs(float64(nums[i]-nums[(i+1)%n])))) } return res }
funcmax(a, b int)int { if a > b { return a } return b }