-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted ordering of categories and topics to be alphabetical due to …
…random set popping order
- Loading branch information
Showing
75 changed files
with
1,753 additions
and
644 deletions.
There are no files selected for viewing
Submodule .Readme Updater
updated
from afa4f6 to 6edac1
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
markdowns/_3168. Minimum Number of Chairs in a Waiting Room.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 3168. [Minimum Number of Chairs in a Waiting Room](<https://leetcode.com/problems/minimum-number-of-chairs-in-a-waiting-room>) - Q1 | ||
|
||
*All prompts are owned by LeetCode. To view the prompt, click the title link above.* | ||
|
||
*[Back to top](<../README.md>)* | ||
|
||
------ | ||
|
||
> *First completed : June 01, 2024* | ||
> | ||
> *Last updated : June 01, 2024* | ||
|
||
------ | ||
|
||
> **Related Topics** : **[String](<by_topic/String.md>), [Simulation](<by_topic/Simulation.md>)** | ||
> | ||
> **Acceptance Rate** : **80.587 %** | ||
|
||
------ | ||
|
||
## Solutions | ||
|
||
- [Weekly Contest 400/e3168 Weekly Contest 400 q1.py](<../my-submissions/Weekly Contest 400/e3168 Weekly Contest 400 q1.py>) | ||
### Python | ||
#### [e3168 Weekly Contest 400 q1.py](<../my-submissions/Weekly Contest 400/e3168 Weekly Contest 400 q1.py>) | ||
```Python | ||
# https://leetcode.com/problems/minimum-number-of-chairs-in-a-waiting-room/description/ | ||
|
||
# Did during Weekly Contest 400 | ||
|
||
class Solution: | ||
def minimumChairs(self, s: str) -> int: | ||
maxx = 0 | ||
curr = 0 | ||
for i in s : | ||
if i == 'L' : | ||
curr = max(0, curr - 1) | ||
else : | ||
curr += 1 | ||
maxx = max(curr, maxx) | ||
return maxx | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# 3169. [Count Days Without Meetings](<https://leetcode.com/problems/count-days-without-meetings>) - Q2 | ||
|
||
*All prompts are owned by LeetCode. To view the prompt, click the title link above.* | ||
|
||
*[Back to top](<../README.md>)* | ||
|
||
------ | ||
|
||
> *First completed : June 01, 2024* | ||
> | ||
> *Last updated : June 01, 2024* | ||
|
||
------ | ||
|
||
> **Related Topics** : **[Array](<by_topic/Array.md>), [Sorting](<by_topic/Sorting.md>)** | ||
> | ||
> **Acceptance Rate** : **33.105 %** | ||
|
||
------ | ||
|
||
## Solutions | ||
|
||
- [Weekly Contest 400/m3169 Weekly Contest 400 q2.py](<../my-submissions/Weekly Contest 400/m3169 Weekly Contest 400 q2.py>) | ||
### Python | ||
#### [m3169 Weekly Contest 400 q2.py](<../my-submissions/Weekly Contest 400/m3169 Weekly Contest 400 q2.py>) | ||
```Python | ||
# https://leetcode.com/problems/count-days-without-meetings/ | ||
|
||
# Did in Weekly-Contest 400 | ||
# https://leetcode.com/contest/weekly-contest-400/ | ||
|
||
''' Notes | ||
days - meetingDays --> but meetingDays has overlaps | ||
days - meetingDays + overlaps = answer | ||
''' | ||
|
||
|
||
class Solution: | ||
def countDays(self, days: int, meetings: List[List[int]]) -> int: | ||
meetings = sorted(meetings) | ||
|
||
currentL, currentR = meetings[0] | ||
counter = currentL - 1 | ||
|
||
# print(meetings) | ||
for met in meetings[1:] : | ||
# print(currentL, currentR) | ||
if met[0] <= currentR : | ||
currentR = max(met[1], currentR) | ||
else : | ||
counter += met[0] - currentR - 1 | ||
currentL, currentR = met | ||
|
||
# print(counter, counter? | ||
counter += days - currentR | ||
return counter | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# 3174. [Clear Digits](<https://leetcode.com/problems/clear-digits>) - Q1 | ||
|
||
*All prompts are owned by LeetCode. To view the prompt, click the title link above.* | ||
|
||
*[Back to top](<../README.md>)* | ||
|
||
------ | ||
|
||
> *First completed : June 08, 2024* | ||
> | ||
> *Last updated : June 08, 2024* | ||
|
||
------ | ||
|
||
> **Related Topics** : **[Hash Table](<by_topic/Hash Table.md>), [String](<by_topic/String.md>), [Simulation](<by_topic/Simulation.md>)** | ||
> | ||
> **Acceptance Rate** : **72.042 %** | ||
|
||
------ | ||
|
||
## Solutions | ||
|
||
- [Biweekly Contest 132/e3174 q1.py](<../my-submissions/Biweekly Contest 132/e3174 q1.py>) | ||
### Python | ||
#### [e3174 q1.py](<../my-submissions/Biweekly Contest 132/e3174 q1.py>) | ||
```Python | ||
# https://leetcode.com/problems/clear-digits/ | ||
|
||
# Pretty bad contest due to server issues and lag to a point where submissions and | ||
# feedback were taking 10+ minutes each... | ||
|
||
# Last week's weekly contest was similar not with lag but with the servers being down | ||
# for the first 15 minutes ;-;;;; | ||
|
||
class Solution: | ||
def clearDigits(self, s: str) -> str: | ||
output = list(s) | ||
|
||
lets = set(list('abcdefghijklmnopqrstuvwxyz')) | ||
nums = set(list('0123456789')) | ||
|
||
for i in range(len(output)) : | ||
if output[i] in nums: | ||
output[i] = '' | ||
for j in range(i - 1, -1, -1) : | ||
if output[j] in lets : | ||
output[j] = '' | ||
break | ||
return ''.join(output) | ||
``` | ||
|
53 changes: 53 additions & 0 deletions
53
markdowns/_3175. Find The First Player to win K Games in a Row.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# 3175. [Find The First Player to win K Games in a Row](<https://leetcode.com/problems/find-the-first-player-to-win-k-games-in-a-row>) - Q2 | ||
|
||
*All prompts are owned by LeetCode. To view the prompt, click the title link above.* | ||
|
||
*[Back to top](<../README.md>)* | ||
|
||
------ | ||
|
||
> *First completed : June 08, 2024* | ||
> | ||
> *Last updated : June 08, 2024* | ||
|
||
------ | ||
|
||
> **Related Topics** : **[Array](<by_topic/Array.md>), [Simulation](<by_topic/Simulation.md>)** | ||
> | ||
> **Acceptance Rate** : **38.974 %** | ||
|
||
------ | ||
|
||
## Solutions | ||
|
||
- [Biweekly Contest 132/m3175 q2.py](<../my-submissions/Biweekly Contest 132/m3175 q2.py>) | ||
### Python | ||
#### [m3175 q2.py](<../my-submissions/Biweekly Contest 132/m3175 q2.py>) | ||
```Python | ||
# https://leetcode.com/problems/find-the-first-player-to-win-k-games-in-a-row/ | ||
|
||
from collections import deque | ||
|
||
class Solution: | ||
def findWinningPlayer(self, skills: List[int], k: int) -> int: | ||
gaming = deque(list(range(0,len(skills)))) | ||
wins = {} | ||
|
||
currentKingOfHill = gaming.popleft() | ||
counter = 0 | ||
while wins.get(currentKingOfHill, 0) < k : | ||
if counter > len(skills) : | ||
return currentKingOfHill | ||
if skills[currentKingOfHill] > skills[gaming[0]] : | ||
gaming.append(gaming.popleft()) | ||
counter += 1 | ||
else : | ||
counter = 0 | ||
gaming.append(currentKingOfHill) | ||
currentKingOfHill = gaming.popleft() | ||
wins[currentKingOfHill] = wins.get(currentKingOfHill, 0) + 1 | ||
return currentKingOfHill | ||
``` | ||
|
40 changes: 40 additions & 0 deletions
40
markdowns/_3178. Find the Child Who Has the Ball After K Seconds.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# 3178. [Find the Child Who Has the Ball After K Seconds](<https://leetcode.com/problems/find-the-child-who-has-the-ball-after-k-seconds>) - Q1 | ||
|
||
*All prompts are owned by LeetCode. To view the prompt, click the title link above.* | ||
|
||
*[Back to top](<../README.md>)* | ||
|
||
------ | ||
|
||
> *First completed : June 08, 2024* | ||
> | ||
> *Last updated : June 08, 2024* | ||
|
||
------ | ||
|
||
> **Related Topics** : **[Math](<by_topic/Math.md>), [Simulation](<by_topic/Simulation.md>)** | ||
> | ||
> **Acceptance Rate** : **62.369 %** | ||
|
||
------ | ||
|
||
## Solutions | ||
|
||
- [Weekly Contest 401/e3178 q1.py](<../my-submissions/Weekly Contest 401/e3178 q1.py>) | ||
### Python | ||
#### [e3178 q1.py](<../my-submissions/Weekly Contest 401/e3178 q1.py>) | ||
```Python | ||
# https://leetcode.com/problems/find-the-child-who-has-the-ball-after-k-seconds/ | ||
# https://leetcode.com/contest/weekly-contest-401/ | ||
|
||
class Solution: | ||
def numberOfChild(self, n: int, k: int) -> int: | ||
k %= (2 * n - 2) | ||
if k >= n : | ||
return (n - 1) - (k - (n - 1)) | ||
return k | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# 3179. [Find the N-th Value After K Seconds](<https://leetcode.com/problems/find-the-n-th-value-after-k-seconds>) - Q2 | ||
|
||
*All prompts are owned by LeetCode. To view the prompt, click the title link above.* | ||
|
||
*[Back to top](<../README.md>)* | ||
|
||
------ | ||
|
||
> *First completed : June 08, 2024* | ||
> | ||
> *Last updated : June 08, 2024* | ||
|
||
------ | ||
|
||
> **Related Topics** : **[Array](<by_topic/Array.md>), [Math](<by_topic/Math.md>), [Simulation](<by_topic/Simulation.md>), [Combinatorics](<by_topic/Combinatorics.md>), [Prefix Sum](<by_topic/Prefix Sum.md>)** | ||
> | ||
> **Acceptance Rate** : **55.648 %** | ||
|
||
------ | ||
|
||
## Solutions | ||
|
||
- [Weekly Contest 401/m3179 q2 brute force but worked.py](<../my-submissions/Weekly Contest 401/m3179 q2 brute force but worked.py>) | ||
### Python | ||
#### [m3179 q2 brute force but worked.py](<../my-submissions/Weekly Contest 401/m3179 q2 brute force but worked.py>) | ||
```Python | ||
# https://leetcode.com/problems/find-the-n-th-value-after-k-seconds/description/ | ||
# https://leetcode.com/contest/weekly-contest-401/ | ||
|
||
class Solution: | ||
def valueAfterKSeconds(self, n: int, k: int) -> int: | ||
output = [1] * n | ||
|
||
for _ in range(k) : | ||
for j in range(1, n) : | ||
output[j] += output[j - 1] | ||
return output[-1] % (10 ** 9 + 7) | ||
|
||
|
||
|
||
''' I DID NOT EXPECT BRUTE FORCE TO WORK- | ||
I wasted so much time trying to find the math behind it lol | ||
1 1 1 1 | ||
1 2 3 4 | ||
1 3 6 10 | ||
1 4 10 20 | ||
0 [0] [1] [2] [3] | ||
1 [0] [0]+[1] a+b+c =0+1+2 a+b+c+d =0+1+2+3 | ||
2 [0] 0+0+1=2a+b 3a+2b+c = 0+0+1+0+1+2 4a+3b+2c+d =0+0+1+0+1+2+0+1+2+3 | ||
3 [0] 3a+b 6a+3b+c 10a+6b+3c+d | ||
4 [0] 4a+b 10a+4b+c 20a+10b+4c+d | ||
5 [0] | ||
6 [0] | ||
7 [0] | ||
0 | ||
1*prev + a 2 * prev | ||
''' | ||
``` | ||
|
Oops, something went wrong.