Dashboard Temp Share Shortlinks Frames API

HTMLify

Day 117
Views: 2 | Author: djdj
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
class Solution {

    /**
     * @param Integer[] $nums
     * @return Integer
     */
    function maxAdjacentDistance($nums) {
        $n = count($nums);
        $max = 0;

        for ($i = 0; $i < $n; $i++) {
            $diff = abs($nums[$i] - $nums[($i + 1) % $n]);
            $max = max($max, $diff);
        }

        return $max;
    }
}