Tap here to switch tabs
Problem
Submissions

Problem: Most Visited Sector in a Circular Track

med
30 min
Try to solve the Most Visited Sector in a Circular Track problem.

Statement

You are given an integer n representing the number of sectors on a circular track, sequentially numbered from 11 to n in clockwise order. You are also given an integer array rounds that defines the sequence of checkpoints in a marathon held on this track.

The marathon begins at sector rounds[0] and moves in a clockwise direction. For each consecutive pair of checkpoints rounds[i] and rounds[i + 1], the marathon travels clockwise from rounds[i] to rounds[i + 1].

Return an array containing the most frequently visited sectors, sorted in ascending order.

Note: A sector is counted as visited every time the runner passes through it or reaches it as a checkpoint.

Constraints:

  • 2≤2 \leq n ≤100\leq 100

  • 1≤1 \leq m ≤100\leq 100

  • rounds.length =m+1= m + 1

  • 1≤1 \leq rounds[i] ≤\leq n

  • rounds[i] ≠\neq rounds[i + 1] for 0≤0 \leq i <m< m

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Most Visited Sector in a Circular Track

med
30 min
Try to solve the Most Visited Sector in a Circular Track problem.

Statement

You are given an integer n representing the number of sectors on a circular track, sequentially numbered from 11 to n in clockwise order. You are also given an integer array rounds that defines the sequence of checkpoints in a marathon held on this track.

The marathon begins at sector rounds[0] and moves in a clockwise direction. For each consecutive pair of checkpoints rounds[i] and rounds[i + 1], the marathon travels clockwise from rounds[i] to rounds[i + 1].

Return an array containing the most frequently visited sectors, sorted in ascending order.

Note: A sector is counted as visited every time the runner passes through it or reaches it as a checkpoint.

Constraints:

  • 2≤2 \leq n ≤100\leq 100

  • 1≤1 \leq m ≤100\leq 100

  • rounds.length =m+1= m + 1

  • 1≤1 \leq rounds[i] ≤\leq n

  • rounds[i] ≠\neq rounds[i + 1] for 0≤0 \leq i <m< m