Java Using Mod
\n\t   static public List mostVisited(int n, int[] rounds) {\n\n\n        int count[] = new int[n + 1];\n\n       int x = rounds[0];\n        for(int i = 0; i <
\n\t   static public List<Integer> mostVisited(int n, int[] rounds) {\n\n\n        int count[] = new int[n + 1];\n\n       int x = rounds[0];\n        for(int i = 0; i < rounds.length - 1; i++) {\n\n\n            int y = rounds[i+1];\n            while (x!=y) {\n                count[x]++;\n                x = (x + 1)%(n+1); // Take mod (n + 1)\n                if(x == 0) {\n                    x = 1;\n                }\n            }\n            x = y;\n            //count[y]++;\n        }\n        count[rounds[rounds.length-1]]++;\n\n        int max = 0;\n        for(int i = 0; i < count.length; i++) {\n            max = Math.max(count[i], max); // Find the max\n        }\n        List<Integer> res = new ArrayList<>();\n\n        for(int i = 0; i < count.length; i++) {\n            if(count[i] == max) {\n                res.add(i );\n            }\n        }\n        return res;\n    }
[]