Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1cf007

Browse files
add 1823
1 parent0f6dce4 commita1cf007

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1823|[Find the Winner of the Circular Game](https://leetcode.com/problems/find-the-winner-of-the-circular-game/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1823.java)||Medium|Array|
1112
|1822|[Sign of the Product of an Array](https://leetcode.com/problems/sign-of-the-product-of-an-array/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1822.java)||Easy|Math|
1213
|1817|[Finding the Users Active Minutes](https://leetcode.com/problems/finding-the-users-active-minutes/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1817.java)||Medium|HashTable|
1314
|1816|[Truncate Sentence](https://leetcode.com/problems/truncate-sentence/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1816.java)||Easy|String|
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
packagecom.fishercoder.solutions;
2+
3+
importjava.util.ArrayList;
4+
importjava.util.List;
5+
6+
publicclass_1823 {
7+
publicstaticclassSolution1 {
8+
publicintfindTheWinner(intn,intk) {
9+
List<Integer>list =newArrayList<>(n);
10+
for (inti =0;i <n;i++) {
11+
list.add(i +1);
12+
}
13+
intstartIndex =0;
14+
while (list.size() !=1) {
15+
intremoveIndex = (startIndex +k -1) %list.size();
16+
list.remove(removeIndex);
17+
startIndex =removeIndex;
18+
}
19+
returnlist.get(0);
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp