Most Visited Sector in a Circular Track LeetCode solution in Java

1
class Solution {
2
public List<Integer> mostVisited(int n, int[] rounds) {
3
var start = rounds[0];
4
var end = rounds[rounds.length - 1];
5
var res = new ArrayList<Integer>();
6
if (start <= end) {
7
for (int i = start; i <= end; i++) res.add(i);
8
} else {
9
for (int i = 1; i <= end; i++) res.add(i);
10
for (int i = start; i <= n; i++) res.add(i);
11
}
12
return res;
13
}
14
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0