Most Visited Sector in a Circular Track Problem
Most Visited Sector in a Circular Track Problem — ExecCode Easy DSA Practice
Solve the Most Visited Sector in a Circular Track problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given an integer n and an integer array rounds. Your task is to compute the required answer and return an array of the most visited sectors sorted in ascending order. We have a circular track which consists of n sectors labeled from 1 to n. A marathon will be held on this track, the marathon consists of m rounds. The i^th round starts at sector rounds[i - 1] and ends at sector rounds[i]. For example, round 1 starts at sector rounds[0] and ends at sector rounds[1].
Examples
Input {"n": 4, "rounds": [1, 3, 1, 2]}; Output [1, 2]. Input {"n": 2, "rounds": [2, 1, 2, 1, 2, 1, 2, 1, 2]}; Output [2]
Constraints
2 <= n <= 100 1 <= m <= 100 rounds.length == m + 1 1 <= rounds[i] <= n rounds[i] != rounds[i + 1] for 0 <= i < m
Practice Most Visited Sector in a Circular Track free on ExecCode. Browse DSA problems, topic map, and placement guides.