Most Visited Sector in a Circular Track LeetCode solution in C++

1
class Solution {
2
public:
3
vector<int> mostVisited(int n, vector<int> &rounds) {
4
vector<int> ans;
5
int size = rounds.size();
6

7
if (rounds[0] <= rounds[size - 1]) {
8
for (int i = rounds[0]; i <= rounds[size - 1]; i++) {
9
ans.push_back(i);
10
}
11
return ans;
12
} else {
13
for (int i = 1; i <= rounds[size - 1]; i++) {
14
ans.push_back(i);
15
}
16

17
for (int i = rounds[0]; i <= n; i++) {
18
ans.push_back(i);
19
}
20
}
21

22
return ans;
23
}
24
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0