Java check first and last
Like a clock, check first and last\npay attention if count cross a circle;\n\ndetails of thoughts: let fr = arr[0] (first), to = arr[m -1] (last);\n1, when fr <
Like a clock, check first and last\npay attention if count cross a circle;\n\ndetails of thoughts: let fr = arr[0] (first), to = arr[m -1] (last);\n1, when fr <= to, cnt for each node [..., n,  n+1(fr), n+1, ..., n + 1(to), n, n, ...]\n2, when fr > to, cnt for each node [n+1, n+1, ..., n + 1(to), n, ... , n,  n+1(fr), n+1, ..., n + 1]\n3, You may find that you don\'t worry about the value of n, n could be 0, 1, 2, 3, ..., whatever it is won\'t influence the result. You just need to check whether it is model 1 or 2 based on fr and to.\n```\n    public List<Integer> mostVisited(int n, int[] rounds) {\n        int len = rounds.length, fr = rounds[0], to = rounds[len - 1];\n        List<Integer> res = new ArrayList<>();\n        if (to >= fr) {     // no circle, such as [1,3,1,2]\n            for (int i = fr; i <= to; i++) res.add(i);\n        } else {            // cross a circle, such as [2,3,2,1]\n            for (int i = 1; i <= n; i++) {\n                if (i == to + 1) i = fr;\n                res.add(i);\n            }\n        }\n        return res;\n    }\n```
[]