mirror of
https://git.wolves.top/wolves/leetcode.git
synced 2025-11-04 17:26:32 +08:00
init
This commit is contained in:
22
23/08/Q2682.cpp
Normal file
22
23/08/Q2682.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Created by 李洋 on 2023/8/16.
|
||||
//
|
||||
#include "vector"
|
||||
using namespace std;
|
||||
class Q2682 {
|
||||
public:
|
||||
vector<int> circularGameLosers(int n, int k) {
|
||||
vector<bool> visit(n, false);
|
||||
for (int i = k, j = 0; !visit[j]; i += k) {
|
||||
visit[j] = true;
|
||||
j = (j + i) % n;
|
||||
}
|
||||
vector<int> ans;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (!visit[i]) {
|
||||
ans.emplace_back(i + 1);
|
||||
}
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user