Faster than 100% solution java
Intuition\n Describe your first thoughts on how to solve this problem. \nThe task is to find the elements which receive the maximum number of visits. So, if the
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe task is to find the elements which receive the maximum number of visits. So, if the whole circular array is traversed once, the number of visits to each element would increase by 1 and therefore, the maximum does not change. Since we are required to traverse in a circular path, the maximum just depends on the starting position and ending position.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe approach is to find the elements that would be covered while traversing from the first element to the last element. If the source is less than the destination, only the elements between the source and destination are covered.\n\nConsider an example:- [1,3] n=4\nWe need to traverse in this order: 1->2->3\ntherefore, the elements in this path will get the maximum number of visits. \n\nAnd in the other case, we need to traverse from the source to the end and again from the beginning to the destination.\n\nConsider another example:- [3,2] n=4\nWe need to traverse in this order: 3->4 and then 4->1->2\n\nIf there are any elements between the starting and the ending position, it doesn\'t matter because fully completed rounds don\'t change the solution. \n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n)\n\n# Code\n```\nclass Solution {\n    public void helper(int a,int b,List<Integer>l)\n    {\n        for(int i=a;i<=b;i++)\n        {\n            l.add(i);\n        }\n    }\n    public List<Integer> mostVisited(int n, int[] rounds) {\n        List<Integer>l=new ArrayList<>();\n        int a=rounds[0];\n        int b=rounds[rounds.length-1];\n        if(a<=b)\n        {\n            helper(a,b,l);\n        }\n        else\n        {\n            helper(1,b,l);\n            helper(a,n,l);\n        }\n        return l;\n    }\n}\n```
['Java']