Easy to understand python solution
initialize a visited array(number of times each sector is visited)\nconsider the test case [1,3,1,2] and n=4\nat first we are at the position rounds[0], so mark
initialize a visited array(number of times each sector is visited)\nconsider the test case [1,3,1,2] and n=4\nat first we are at the position rounds[0], so marking vis[rounds[0]]=1\n\nstep 1: going from 1-3\n\t3 is greater than 1,it satifies the first if condition:\n\tlooping from 1+1 to 3 and incrementing the visited count of each sector in vis array (vis becomes=[1,1,1,0])\n\t\nstep 2: going from 3-1\n\tas 1 is less than 3, it doesn\'t satisfies the if condition and goes to else:\n\tlooping from 3+1 to 4(as 4 is n) and then looping from start(i.e., 1) to 1 and incrementing the vis count (vis becomes=[2,1,1,1])\n\t\nstep 3: going from 1-2\n\tas 2 is greater then 1 , it satisfies the if condition:\n\tlooping from 1+1 to 2 and incrementing the count of number of time visited in vis array (vis array becomes=[2,2,1,1])\n\t\nnow our visited array is [2,2,1,1] in which maximum is 2\nso appending all the sectors whose count is 2 in visited array to ans array\nfinally returning ans array\n\ncode:\n\n```\nclass Solution:\n    def mostVisited(self, n: int, l: List[int]) -> List[int]:\n        vis=[0]*(n+1)\n        vis[l[0]]=1\n        for i in range(1,len(l)):\n            if(l[i-1]<=l[i]):\n                for j in range(l[i-1]+1,l[i]+1):\n                    vis[j]+=1\n            else:\n                for j in range(l[i-1]+1,n+1):\n                    vis[j]+=1\n                for j in range(1,l[i]+1):\n                    vis[j]+=1\n        ans=[]\n        m=max(vis)\n        for i in range(len(vis)):\n            if(vis[i]==m):\n                ans.append(i)\n        return ans\n        \n```\n\nupvote if you like it :)
[]