Skip to content

Commit

Permalink
Weekly contest 405 - First time getting 3/4 and for some reason it w…
Browse files Browse the repository at this point in the history
…as Qs 1, 2, and 4 but not 3 lol
  • Loading branch information
Zanger67 committed Jul 7, 2024
1 parent 7935c9c commit 7e12ada
Show file tree
Hide file tree
Showing 57 changed files with 641 additions and 423 deletions.
2 changes: 1 addition & 1 deletion .Readme Updater
141 changes: 72 additions & 69 deletions README.md

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions markdowns/Daily_Questions.md

Large diffs are not rendered by default.

137 changes: 70 additions & 67 deletions markdowns/Questions_By_Code_Length.md

Large diffs are not rendered by default.

137 changes: 70 additions & 67 deletions markdowns/Questions_By_Recent.md

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions markdowns/_1518. Water Bottles.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
- [e1518 v1 O(n) Daily.py](<../my-submissions/e1518 v1 O(n) Daily.py>)
- [e1518 v2 O(1).py](<../my-submissions/e1518 v2 O(1).py>)
- [e1518.c](<../my-submissions/e1518.c>)
- [e1518.cpp](<../my-submissions/e1518.cpp>)
- [e1518.cs](<../my-submissions/e1518.cs>)
- [e1518.java](<../my-submissions/e1518.java>)
- [e1518.js](<../my-submissions/e1518.js>)
- [e1518.ts](<../my-submissions/e1518.ts>)
- [e1518 v2.c](<../my-submissions/e1518 v2.c>)
- [e1518 v2.cpp](<../my-submissions/e1518 v2.cpp>)
- [e1518 v2.cs](<../my-submissions/e1518 v2.cs>)
- [e1518 v2.java](<../my-submissions/e1518 v2.java>)
- [e1518 v2.js](<../my-submissions/e1518 v2.js>)
- [e1518 v2.ts](<../my-submissions/e1518 v2.ts>)
### Python
#### [e1518 v1 O(n) Daily.py](<../my-submissions/e1518 v1 O(n) Daily.py>)
```Python
Expand All @@ -80,15 +80,15 @@ class Solution:
```

### C
#### [e1518.c](<../my-submissions/e1518.c>)
#### [e1518 v2.c](<../my-submissions/e1518 v2.c>)
```C
int numWaterBottles(int numBottles, int numExchange) {
return numBottles + (numBottles - 1) / (numExchange - 1);
}
```
### C++
#### [e1518.cpp](<../my-submissions/e1518.cpp>)
#### [e1518 v2.cpp](<../my-submissions/e1518 v2.cpp>)
```C++
class Solution {
public:
Expand All @@ -99,7 +99,7 @@ public:
```

### C#
#### [e1518.cs](<../my-submissions/e1518.cs>)
#### [e1518 v2.cs](<../my-submissions/e1518 v2.cs>)
```C#
public class Solution {
public int NumWaterBottles(int numBottles, int numExchange) {
Expand All @@ -109,7 +109,7 @@ public class Solution {
```

### Java
#### [e1518.java](<../my-submissions/e1518.java>)
#### [e1518 v2.java](<../my-submissions/e1518 v2.java>)
```Java
class Solution {
public int numWaterBottles(int numBottles, int numExchange) {
Expand All @@ -119,7 +119,7 @@ class Solution {
```

### JavaScript
#### [e1518.js](<../my-submissions/e1518.js>)
#### [e1518 v2.js](<../my-submissions/e1518 v2.js>)
```JavaScript
/**
* @param {number} numBottles
Expand All @@ -132,7 +132,7 @@ var numWaterBottles = function(numBottles, numExchange) {
```

### TypeScript
#### [e1518.ts](<../my-submissions/e1518.ts>)
#### [e1518 v2.ts](<../my-submissions/e1518 v2.ts>)
```TypeScript
function numWaterBottles(numBottles: number, numExchange: number): number {
return numBottles + Math.floor((numBottles - 1) / (numExchange - 1));
Expand Down
34 changes: 34 additions & 0 deletions markdowns/_3210. w contest 405 - q.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 3210. w contest 405 - q1

*All prompts are owned by LeetCode. To view the prompt, click the title link above.*

*[Back to top](<../README.md>)*

------

> *First completed : July 06, 2024*
>
> *Last updated : July 06, 2024*

------

> **Related Topics** : **[N](<by_topic/N.md>), [/](</.md>), [A](<by_topic/A.md>)**
>
> **Acceptance Rate** : **Unknown**

------

## Solutions

- [w contest 405/e3210 q1.py](<../my-submissions/w contest 405/e3210 q1.py>)
### Python
#### [e3210 q1.py](<../my-submissions/w contest 405/e3210 q1.py>)
```Python
class Solution:
def getEncryptedString(self, s: str, k: int) -> str:
k %= len(s)
return s[k:] + s[:k]
```

53 changes: 53 additions & 0 deletions markdowns/_3211. w contest 405 - q.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 3211. w contest 405 - q2

*All prompts are owned by LeetCode. To view the prompt, click the title link above.*

*[Back to top](<../README.md>)*

------

> *First completed : July 06, 2024*
>
> *Last updated : July 06, 2024*

------

> **Related Topics** : **[N](<by_topic/N.md>), [/](</.md>), [A](<by_topic/A.md>)**
>
> **Acceptance Rate** : **Unknown**

------

## Solutions

- [w contest 405/m3211 q2.py](<../my-submissions/w contest 405/m3211 q2.py>)
### Python
#### [m3211 q2.py](<../my-submissions/w contest 405/m3211 q2.py>)
```Python
class Solution:
def validStrings(self, n: int) -> List[str]:
output = []

def dfs(curr: List[str],
output: List[str],
remaining: int,
prevIsOne: bool) -> None :
if not remaining :
output.append(''.join(curr))
return

curr.append('1')
remaining -= 1
dfs(curr, output, remaining, True)
curr.pop()

if prevIsOne :
curr.append('0')
dfs(curr, output, remaining, False)
curr.pop()
dfs([], output, n, True)
return output
```

66 changes: 66 additions & 0 deletions markdowns/_3213. w contest 405 - q.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 3213. w contest 405 - q4

*All prompts are owned by LeetCode. To view the prompt, click the title link above.*

*[Back to top](<../README.md>)*

------

> *First completed : July 06, 2024*
>
> *Last updated : July 06, 2024*

------

> **Related Topics** : **[N](<by_topic/N.md>), [/](</.md>), [A](<by_topic/A.md>)**
>
> **Acceptance Rate** : **Unknown**

------

## Solutions

- [w contest 405/h3213 q4.py](<../my-submissions/w contest 405/h3213 q4.py>)
- [w contest 405/h3213.md](<../my-submissions/w contest 405/h3213.md>)
### Python
#### [h3213 q4.py](<../my-submissions/w contest 405/h3213 q4.py>)
```Python
class Solution:
def minimumCost(self, target: str, words: List[str], costs: List[int]) -> int:
wordToCost = {}
for w, c in zip(words, costs) :
if w in wordToCost and wordToCost[w] <= c :
continue
wordToCost[w] = c

words = sorted(list(set(words)), key=lambda x: len(x))
maxWrd = len(words) - 1

dp = [0] + [inf] * len(target)

for i in range(len(target)) :
while maxWrd >= 0 and len(words[maxWrd]) > len(target) - i :
maxWrd -= 1
if maxWrd < 0 :
break

for word in words[:maxWrd + 1] :
if word == target[i:i+len(word)] :
dp[i + len(word)] = min(dp[i + len(word)], dp[i] + wordToCost[word])

return -1 if dp[-1] == inf else dp[-1]

```

### md
#### [h3213.md](<../my-submissions/w contest 405/h3213.md>)
```md
Did the contest live and got through Q1 & Q2 very quickly. When I saw Q3 however,
I got really confused so I decided to just skip it for now. Somehow, I was able to get
Q4 then when I got back to Q3, I realized what the solution was and laid out the steps,
but didn't have enough time to implement it. So yeah... good contest lol. First time
getting 3 questions too funny enough lol.
```

Loading

0 comments on commit 7e12ada

Please sign in to comment.