Skip to content

Commit 6fd3268

Browse files
committed
Daily
1 parent 2e01f4e commit 6fd3268

13 files changed

+88
-12
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# **[LeetCode Records](https://leetcode.com/u/Zanger/)** (405 solved)
1+
# **[LeetCode Records](https://leetcode.com/u/Zanger/)** (406 solved)
22

33
> My LeetCode Profile: [Zanger](https://leetcode.com/u/Zanger/)
44
@@ -28,7 +28,7 @@ This repo is a collection of my LeetCode solutions, primarily written in Python,
2828

2929
------
3030

31-
[Array](<markdowns/by_topic/Array.md>), [Hash Table](<markdowns/by_topic/Hash Table.md>), [String](<markdowns/by_topic/String.md>), [Depth-First Search](<markdowns/by_topic/Depth-First Search.md>), [Tree](<markdowns/by_topic/Tree.md>), [Binary Tree](<markdowns/by_topic/Binary Tree.md>), [Sorting](<markdowns/by_topic/Sorting.md>), [Math](<markdowns/by_topic/Math.md>), [Breadth-First Search](<markdowns/by_topic/Breadth-First Search.md>), [Two Pointers](<markdowns/by_topic/Two Pointers.md>), [Linked List](<markdowns/by_topic/Linked List.md>), [Stack](<markdowns/by_topic/Stack.md>), [Greedy](<markdowns/by_topic/Greedy.md>), [Matrix](<markdowns/by_topic/Matrix.md>), [Simulation](<markdowns/by_topic/Simulation.md>), [Bit Manipulation](<markdowns/by_topic/Bit Manipulation.md>), [Design](<markdowns/by_topic/Design.md>), [Dynamic Programming](<markdowns/by_topic/Dynamic Programming.md>), [Binary Search](<markdowns/by_topic/Binary Search.md>), [Database](<markdowns/by_topic/Database.md>), [Trie](<markdowns/by_topic/Trie.md>), [Counting](<markdowns/by_topic/Counting.md>), [Heap (Priority Queue)](<markdowns/by_topic/Heap (Priority Queue).md>), [Recursion](<markdowns/by_topic/Recursion.md>), [Backtracking](<markdowns/by_topic/Backtracking.md>), [Binary Search Tree](<markdowns/by_topic/Binary Search Tree.md>), [Sliding Window](<markdowns/by_topic/Sliding Window.md>), [Prefix Sum](<markdowns/by_topic/Prefix Sum.md>), [Queue](<markdowns/by_topic/Queue.md>), [Monotonic Stack](<markdowns/by_topic/Monotonic Stack.md>), [Union Find](<markdowns/by_topic/Union Find.md>), [Divide and Conquer](<markdowns/by_topic/Divide and Conquer.md>), [String Matching](<markdowns/by_topic/String Matching.md>), [Graph](<markdowns/by_topic/Graph.md>), [Hash Function](<markdowns/by_topic/Hash Function.md>), [Combinatorics](<markdowns/by_topic/Combinatorics.md>), [Randomized](<markdowns/by_topic/Randomized.md>), [Monotonic Queue](<markdowns/by_topic/Monotonic Queue.md>), [Doubly-Linked List](<markdowns/by_topic/Doubly-Linked List.md>), [Iterator](<markdowns/by_topic/Iterator.md>), [Bucket Sort](<markdowns/by_topic/Bucket Sort.md>), [Geometry](<markdowns/by_topic/Geometry.md>), [Counting Sort](<markdowns/by_topic/Counting Sort.md>), [Brainteaser](<markdowns/by_topic/Brainteaser.md>), [Game Theory](<markdowns/by_topic/Game Theory.md>), [Interactive](<markdowns/by_topic/Interactive.md>), [Memoization](<markdowns/by_topic/Memoization.md>), [Data Stream](<markdowns/by_topic/Data Stream.md>), [Rolling Hash](<markdowns/by_topic/Rolling Hash.md>), [Quickselect](<markdowns/by_topic/Quickselect.md>), [Bitmask](<markdowns/by_topic/Bitmask.md>), [Merge Sort](<markdowns/by_topic/Merge Sort.md>), [Ordered Set](<markdowns/by_topic/Ordered Set.md>), [Suffix Array](<markdowns/by_topic/Suffix Array.md>), [Topological Sort](<markdowns/by_topic/Topological Sort.md>), [Shortest Path](<markdowns/by_topic/Shortest Path.md>), [Number Theory](<markdowns/by_topic/Number Theory.md>), [Reservoir Sampling](<markdowns/by_topic/Reservoir Sampling.md>)
31+
[Array](<markdowns/by_topic/Array.md>), [Hash Table](<markdowns/by_topic/Hash Table.md>), [String](<markdowns/by_topic/String.md>), [Depth-First Search](<markdowns/by_topic/Depth-First Search.md>), [Tree](<markdowns/by_topic/Tree.md>), [Binary Tree](<markdowns/by_topic/Binary Tree.md>), [Sorting](<markdowns/by_topic/Sorting.md>), [Math](<markdowns/by_topic/Math.md>), [Breadth-First Search](<markdowns/by_topic/Breadth-First Search.md>), [Two Pointers](<markdowns/by_topic/Two Pointers.md>), [Linked List](<markdowns/by_topic/Linked List.md>), [Stack](<markdowns/by_topic/Stack.md>), [Greedy](<markdowns/by_topic/Greedy.md>), [Matrix](<markdowns/by_topic/Matrix.md>), [Simulation](<markdowns/by_topic/Simulation.md>), [Bit Manipulation](<markdowns/by_topic/Bit Manipulation.md>), [Design](<markdowns/by_topic/Design.md>), [Dynamic Programming](<markdowns/by_topic/Dynamic Programming.md>), [Binary Search](<markdowns/by_topic/Binary Search.md>), [Database](<markdowns/by_topic/Database.md>), [Trie](<markdowns/by_topic/Trie.md>), [Counting](<markdowns/by_topic/Counting.md>), [Heap (Priority Queue)](<markdowns/by_topic/Heap (Priority Queue).md>), [Recursion](<markdowns/by_topic/Recursion.md>), [Backtracking](<markdowns/by_topic/Backtracking.md>), [Binary Search Tree](<markdowns/by_topic/Binary Search Tree.md>), [Sliding Window](<markdowns/by_topic/Sliding Window.md>), [Queue](<markdowns/by_topic/Queue.md>), [Prefix Sum](<markdowns/by_topic/Prefix Sum.md>), [Monotonic Stack](<markdowns/by_topic/Monotonic Stack.md>), [Union Find](<markdowns/by_topic/Union Find.md>), [Divide and Conquer](<markdowns/by_topic/Divide and Conquer.md>), [String Matching](<markdowns/by_topic/String Matching.md>), [Graph](<markdowns/by_topic/Graph.md>), [Hash Function](<markdowns/by_topic/Hash Function.md>), [Combinatorics](<markdowns/by_topic/Combinatorics.md>), [Randomized](<markdowns/by_topic/Randomized.md>), [Monotonic Queue](<markdowns/by_topic/Monotonic Queue.md>), [Doubly-Linked List](<markdowns/by_topic/Doubly-Linked List.md>), [Iterator](<markdowns/by_topic/Iterator.md>), [Bucket Sort](<markdowns/by_topic/Bucket Sort.md>), [Geometry](<markdowns/by_topic/Geometry.md>), [Counting Sort](<markdowns/by_topic/Counting Sort.md>), [Brainteaser](<markdowns/by_topic/Brainteaser.md>), [Game Theory](<markdowns/by_topic/Game Theory.md>), [Interactive](<markdowns/by_topic/Interactive.md>), [Memoization](<markdowns/by_topic/Memoization.md>), [Data Stream](<markdowns/by_topic/Data Stream.md>), [Rolling Hash](<markdowns/by_topic/Rolling Hash.md>), [Quickselect](<markdowns/by_topic/Quickselect.md>), [Bitmask](<markdowns/by_topic/Bitmask.md>), [Merge Sort](<markdowns/by_topic/Merge Sort.md>), [Ordered Set](<markdowns/by_topic/Ordered Set.md>), [Suffix Array](<markdowns/by_topic/Suffix Array.md>), [Topological Sort](<markdowns/by_topic/Topological Sort.md>), [Shortest Path](<markdowns/by_topic/Shortest Path.md>), [Number Theory](<markdowns/by_topic/Number Theory.md>), [Reservoir Sampling](<markdowns/by_topic/Reservoir Sampling.md>)
3232

3333
------
3434

@@ -344,6 +344,7 @@ This repo is a collection of my LeetCode solutions, primarily written in Python,
344344
| 1791 | [Find Center of Star Graph](<https://leetcode.com/problems/find-center-of-star-graph>) | Easy | Daily | [solution](<markdowns/_1791. Find Center of Star Graph.md>) | c, cpp, java, py |
345345
| 1804 | [Implement Trie II (Prefix Tree)](<https://leetcode.com/problems/implement-trie-ii-prefix-tree>) | Medium | | [solution](<markdowns/_1804. Implement Trie II (Prefix Tree).md>) | py |
346346
| 1822 | [Sign of the Product of an Array](<https://leetcode.com/problems/sign-of-the-product-of-an-array>) | Easy | | [solution](<markdowns/_1822. Sign of the Product of an Array.md>) | c |
347+
| 1823 | [Find the Winner of the Circular Game](<https://leetcode.com/problems/find-the-winner-of-the-circular-game>) | Medium | Daily | [solution](<markdowns/_1823. Find the Winner of the Circular Game.md>) | py |
347348
| 1833 | [Maximum Ice Cream Bars](<https://leetcode.com/problems/maximum-ice-cream-bars>) | Medium | | [solution](<markdowns/_1833. Maximum Ice Cream Bars.md>) | c, java, py |
348349
| 1836 | [Remove Duplicates From an Unsorted Linked List](<https://leetcode.com/problems/remove-duplicates-from-an-unsorted-linked-list>) | Medium | | [solution](<markdowns/_1836. Remove Duplicates From an Unsorted Linked List.md>) | py |
349350
| 1844 | [Replace All Digits with Characters](<https://leetcode.com/problems/replace-all-digits-with-characters>) | Easy | | [solution](<markdowns/_1844. Replace All Digits with Characters.md>) | py |

markdowns/Daily_Questions.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Dates are for the date I completed the question so due to the my time zone and h
66

77
| # | Title | Level | Cats | Solution | Languages | Date Complete |
88
|-----:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|:------------|:---------------------------------------------------------------------------------------------------|:-----------------------------|:----------------|
9+
| 1823 | [Find the Winner of the Circular Game](<https://leetcode.com/problems/find-the-winner-of-the-circular-game>) | Medium | Daily | [solution](<_1823. Find the Winner of the Circular Game.md>) | py | Jul 07, 2024 |
910
| 1518 | [Water Bottles](<https://leetcode.com/problems/water-bottles>) | Easy | Daily | [solution](<_1518. Water Bottles.md>) | c, cpp, cs, java, js, py, ts | Jul 06, 2024 |
1011
| 2582 | [Pass the Pillow](<https://leetcode.com/problems/pass-the-pillow>) | Easy | Daily | [solution](<_2582. Pass the Pillow.md>) | c, cpp, cs, java, js, py | Jul 05, 2024 |
1112
| 2058 | [Find the Minimum and Maximum Number of Nodes Between Critical Points](<https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points>) | Medium | Daily | [solution](<_2058. Find the Minimum and Maximum Number of Nodes Between Critical Points.md>) | cpp, java, py | Jul 04, 2024 |

markdowns/Questions_By_Code_Length.md

+1
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ Calculations are based on the code files's byte sizes.
312312
| 235 | [Lowest Common Ancestor of a Binary Search Tree](<https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree>) | Medium | B75, N150 | [solution](<_235. Lowest Common Ancestor of a Binary Search Tree.md>) | py | Jul 04, 2024 |
313313
| 1317 | [Convert Integer to the Sum of Two No-Zero Integers](<https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers>) | Easy | | [solution](<_1317. Convert Integer to the Sum of Two No-Zero Integers.md>) | c | Jun 04, 2024 |
314314
| 1046 | [Last Stone Weight](<https://leetcode.com/problems/last-stone-weight>) | Easy | N150 | [solution](<_1046. Last Stone Weight.md>) | py | Jun 03, 2024 |
315+
| 1823 | [Find the Winner of the Circular Game](<https://leetcode.com/problems/find-the-winner-of-the-circular-game>) | Medium | Daily | [solution](<_1823. Find the Winner of the Circular Game.md>) | py | Jul 07, 2024 |
315316
| 2942 | [Find Words Containing Character](<https://leetcode.com/problems/find-words-containing-character>) | Easy | | [solution](<_2942. Find Words Containing Character.md>) | c | Jun 03, 2024 |
316317
| 654 | [Maximum Binary Tree](<https://leetcode.com/problems/maximum-binary-tree>) | Medium | | [solution](<_654. Maximum Binary Tree.md>) | py | Jun 11, 2024 |
317318
| 287 | [Find the Duplicate Number](<https://leetcode.com/problems/find-the-duplicate-number>) | Medium | N150 | [solution](<_287. Find the Duplicate Number.md>) | c | Jun 25, 2024 |

markdowns/Questions_By_Recent.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Calculations are based on the date of the first solve.
66

77
| # | Title | Level | Cats | Solution | Languages | Date Complete |
88
|-----:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|:---------------|:---------------------------------------------------------------------------------------------------|:---------------------------------|:----------------|
9+
| 1823 | [Find the Winner of the Circular Game](<https://leetcode.com/problems/find-the-winner-of-the-circular-game>) | Medium | Daily | [solution](<_1823. Find the Winner of the Circular Game.md>) | py | Jul 07, 2024 |
910
| 3212 | [Count Submatrices With Equal Frequency of X and Y](<https://leetcode.com/problems/count-submatrices-with-equal-frequency-of-x-and-y>) - q3 | Medium | Contest | [solution](<_3212. Count Submatrices With Equal Frequency of X and Y.md>) | py | Jul 06, 2024 |
1011
| 3213 | [Construct String with Minimum Cost](<https://leetcode.com/problems/construct-string-with-minimum-cost>) - q4 | Hard | Contest | [solution](<_3213. Construct String with Minimum Cost.md>) | py | Jul 06, 2024 |
1112
| 3211 | [Generate Binary Strings Without Adjacent Zeros](<https://leetcode.com/problems/generate-binary-strings-without-adjacent-zeros>) - q2 | Medium | Contest | [solution](<_3211. Generate Binary Strings Without Adjacent Zeros.md>) | py | Jul 06, 2024 |

markdowns/Topics.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
------
66

7-
- [Array](<by_topic/Array.md>) (190 completed)
7+
- [Array](<by_topic/Array.md>) (191 completed)
88
- [Hash Table](<by_topic/Hash Table.md>) (92 completed)
99
- [String](<by_topic/String.md>) (88 completed)
1010
- [Depth-First Search](<by_topic/Depth-First Search.md>) (68 completed)
1111
- [Tree](<by_topic/Tree.md>) (66 completed)
1212
- [Binary Tree](<by_topic/Binary Tree.md>) (61 completed)
1313
- [Sorting](<by_topic/Sorting.md>) (57 completed)
14-
- [Math](<by_topic/Math.md>) (51 completed)
14+
- [Math](<by_topic/Math.md>) (52 completed)
1515
- [Breadth-First Search](<by_topic/Breadth-First Search.md>) (47 completed)
1616
- [Two Pointers](<by_topic/Two Pointers.md>) (46 completed)
1717
- [Linked List](<by_topic/Linked List.md>) (40 completed)
1818
- [Stack](<by_topic/Stack.md>) (37 completed)
1919
- [Greedy](<by_topic/Greedy.md>) (32 completed)
2020
- [Matrix](<by_topic/Matrix.md>) (31 completed)
21-
- [Simulation](<by_topic/Simulation.md>) (27 completed)
21+
- [Simulation](<by_topic/Simulation.md>) (28 completed)
2222
- [Bit Manipulation](<by_topic/Bit Manipulation.md>) (25 completed)
2323
- [Design](<by_topic/Design.md>) (25 completed)
2424
- [Dynamic Programming](<by_topic/Dynamic Programming.md>) (23 completed)
@@ -27,12 +27,12 @@
2727
- [Trie](<by_topic/Trie.md>) (18 completed)
2828
- [Counting](<by_topic/Counting.md>) (17 completed)
2929
- [Heap (Priority Queue)](<by_topic/Heap (Priority Queue).md>) (16 completed)
30-
- [Recursion](<by_topic/Recursion.md>) (14 completed)
30+
- [Recursion](<by_topic/Recursion.md>) (15 completed)
3131
- [Backtracking](<by_topic/Backtracking.md>) (13 completed)
3232
- [Binary Search Tree](<by_topic/Binary Search Tree.md>) (13 completed)
3333
- [Sliding Window](<by_topic/Sliding Window.md>) (13 completed)
34+
- [Queue](<by_topic/Queue.md>) (11 completed)
3435
- [Prefix Sum](<by_topic/Prefix Sum.md>) (11 completed)
35-
- [Queue](<by_topic/Queue.md>) (10 completed)
3636
- [Monotonic Stack](<by_topic/Monotonic Stack.md>) (9 completed)
3737
- [Union Find](<by_topic/Union Find.md>) (8 completed)
3838
- [Divide and Conquer](<by_topic/Divide and Conquer.md>) (6 completed)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# 1823. [Find the Winner of the Circular Game](<https://leetcode.com/problems/find-the-winner-of-the-circular-game>)
2+
3+
*All prompts are owned by LeetCode. To view the prompt, click the title link above.*
4+
5+
*[Back to top](<../README.md>)*
6+
7+
------
8+
9+
> *First completed : July 07, 2024*
10+
>
11+
> *Last updated : July 07, 2024*
12+
13+
14+
------
15+
16+
> **Related Topics** : **[Array](<by_topic/Array.md>), [Math](<by_topic/Math.md>), [Recursion](<by_topic/Recursion.md>), [Queue](<by_topic/Queue.md>), [Simulation](<by_topic/Simulation.md>)**
17+
>
18+
> **Acceptance Rate** : **78.528 %**
19+
20+
21+
------
22+
23+
## Solutions
24+
25+
- [m1823 v1 Daily O(n^2).py](<../my-submissions/m1823 v1 Daily O(n^2).py>)
26+
- [m1823 v2 Daily O(n) Recursive Josephus Problem.py](<../my-submissions/m1823 v2 Daily O(n) Recursive Josephus Problem.py>)
27+
### Python
28+
#### [m1823 v1 Daily O(n^2).py](<../my-submissions/m1823 v1 Daily O(n^2).py>)
29+
```Python
30+
# n^2 comes from popping being an O(n) operation for a list
31+
# This could be improved using a deque where we keep adding the
32+
# popped elements until we reach a removal case.
33+
34+
class Solution:
35+
def findTheWinner(self, n: int, k: int) -> int:
36+
curr = list(range(1, n + 1))
37+
indx = k - 1
38+
while len(curr) > 1 :
39+
curr.pop(indx)
40+
indx = (indx + k - 1) % len(curr)
41+
42+
return curr[0]
43+
```
44+
45+
#### [m1823 v2 Daily O(n) Recursive Josephus Problem.py](<../my-submissions/m1823 v2 Daily O(n) Recursive Josephus Problem.py>)
46+
```Python
47+
class Solution:
48+
def findTheWinner(self, n: int, k: int) -> int:
49+
return 1 if n == 1 else (1 + (self.findTheWinner(n - 1, k) + k - 1) % n)
50+
```
51+

0 commit comments

Comments
 (0)