8000 update 1823 · githubniraj/Leetcode@7506736 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 7506736

Browse files
update 1823
1 parent 72c89cd commit 7506736

File tree

1 file changed

+3
-2
lines changed
  • src/main/java/com/fishercoder/solutions/secondthousand

1 file changed

+3
-2
lines changed

src/main/java/com/fishercoder/solutions/secondthousand/_1823.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ public int findTheWinner(int n, int k) {
2424

2525
public static class Solution2 {
2626
/**
27-
* My completely original solution: use a double linked list to keep moving people from
28-
* the tail of the queue to the head of the queue until there's only one person in the queue who is the winner.
27+
* My completely original solution: use a double linked list to keep moving (k - 1) people from
28+
* the tail of the queue to the head of the queue, and then remove the kth person,
29+
* until there's only one person in the queue who is the winner.
2930
*/
3031
public int findTheWinner(int n, int k) {
3132
Deque<Integer> doublyLinkedList = new LinkedList<>();

0 commit comments

Comments
 (0)
0