2025-08-03 12:13:16 +0000 UTC

Most Visited Sector in a Circular Track

Code

class Solution:
    def mostVisited(self, n: int, rounds: List[int]) -> List[int]:
        start_sector, end_sector = rounds[0], rounds[-1]

        if start_sector <= end_sector:
            return tuple(range(start_sector, end_sector + 1))
            
        return tuple(
            itertools.chain(
                range(1, end_sector + 1),
                range(start_sector, n + 1)
            )
        )