Java Solution with simple explaination
Consider rounds[0] as start of marathon and rounds[A.length-1] as end of marathon, We are running from 1 to n repeatedly.\n\nMost visited sectors can be identif
Consider rounds[0] as **start** of marathon and rounds[A.length-1] as **end** of marathon, We are running from 1 to n repeatedly.\n\nMost visited sectors can be identified from start and end point, **In between how many rounds we run, it doesn\'t matter.**\n\nif(start <= end) we have most visited all sectors between start and end.\n\nif(start > end) then we have to add all from (start to n) and (1 to end).\n\n\tpublic List<Integer> mostVisited(int n, int[] R) {\n\n\t\tint start = R[0];\n\t\tint end = R[R.length - 1];\n\n\t\tList<Integer> res = new ArrayList<>();\n\n\t\tif(start <= end){\n\t\t\tfor (int i = start; i <= end ; ++i) res.add(i);\n\t\t}else{\n\t\t\tfor (int i = 1; i <= end; ++i)  res.add(i);  // count first visited\n\t\t\tfor (int i = start; i <= n; ++i)  res.add(i); // count last visited.\n\t\t}\n\t\treturn res;\n\t}
[]