Most Visited Sector in a Circular Track

给一个circular数组, 有n个数字, 给一个数组代表访问的位置, 任意两个位置只能逆时针旋转. 问访问次数最多的数字.

这个题主要是因为只能一侧旋转, 所以只需要关心访问的第一个和最后一个即可.

class Solution {
    public List<Integer> mostVisited(int n, int[] rounds) {
        List<Integer> res = new ArrayList<>(); 
        if(rounds[0] <= rounds[rounds.length - 1]) {
            for(int i = rounds[0]; i <= rounds[rounds.length - 1]; i++) {
                res.add(i);
            }
        } else {
            for(int i = 1; i <= n; i++) {
                if(i >= rounds[0] || i <= rounds[rounds.length - 1])
                    res.add(i);
            }
        }
        return res;
    }
}