O(n)
public List mostVisited(int n, int[] rounds) {\n        \n        Map map = new TreeMap<>();    \n        List list = new ArrayList<>();\n        \n        int 
public List<Integer> mostVisited(int n, int[] rounds) {\n        \n        Map<Integer,Integer> map = new TreeMap<>();    \n        List<Integer> list = new ArrayList<>();\n        \n        int i=rounds[0];\n        int counter =0;\n        while(counter<rounds.length){\n            map.put(i,map.getOrDefault(i,0)+1);\n            if(i<n){\n             if(i==rounds[counter]){\n                counter++;\n                }  \n              i++;   \n            }\n            else if(i==n){\n              if(i==rounds[counter]){\n                counter++;\n                }     \n              i=1;\n            }\n        }\n                \n        int maxValue = Integer.MIN_VALUE;\n        \n        for(Map.Entry<Integer,Integer> e : map.entrySet()){\n            if(e.getValue()>maxValue){\n                maxValue=e.getValue();\n                list = new ArrayList<>(Arrays.asList(e.getKey()));\n            }else if(e.getValue()==maxValue){\n                list.add(e.getKey());\n            }\n        }\n    \n        return list;\n    }
[]