Skip to content

Commit d0e0708

Browse files
Zanger67/leetcodeZanger67/leetcode
authored andcommitted
Updated markdown files
1 parent cd21802 commit d0e0708

File tree

8 files changed

+79
-6
lines changed

8 files changed

+79
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# **[LeetCode Records](https://leetcode.com/u/Zanger/)** (626 solved)
1+
# **[LeetCode Records](https://leetcode.com/u/Zanger/)** (627 solved)
22

33
<!-- This readme was generated using [WikiLeet](<https://github.com/Zanger67/WikiLeet>) -->
44

@@ -64,6 +64,7 @@ This repo is a collection of my LeetCode solutions, primarily written in Python,
6464
| 28 | [Find the Index of the First Occurrence in a String](<https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string>) | Easy | | [solution](<markdowns/_28. Find the Index of the First Occurrence in a String.md>) | py |
6565
| 33 | [Search in Rotated Sorted Array](<https://leetcode.com/problems/search-in-rotated-sorted-array>) | Medium | B75, N150 | [solution](<markdowns/_33. Search in Rotated Sorted Array.md>) | py |
6666
| 36 | [Valid Sudoku](<https://leetcode.com/problems/valid-sudoku>) | Medium | N150 | [solution](<markdowns/_36. Valid Sudoku.md>) | py |
67+
| 38 | [Count and Say](<https://leetcode.com/problems/count-and-say>) | Medium | Daily | [solution](<markdowns/_38. Count and Say.md>) | py |
6768
| 39 | [Combination Sum](<https://leetcode.com/problems/combination-sum>) | Medium | B75, N150 | [solution](<markdowns/_39. Combination Sum.md>) | py |
6869
| 40 | [Combination Sum II](<https://leetcode.com/problems/combination-sum-ii>) | Medium | Daily, N150 | [solution](<markdowns/_40. Combination Sum II.md>) | py |
6970
| 42 | [Trapping Rain Water](<https://leetcode.com/problems/trapping-rain-water>) | Hard | N150 | [solution](<markdowns/_42. Trapping Rain Water.md>) | py |

markdowns/Daily_Questions.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ Dates are for the date I completed the question so due to the my time zone and h
99
|-------------------------------------:|-------------------------------------------:|---------------------------------------------------------------------------------:|-------------------------------------------------------:|-----:|---------------------------------------------:|-----:|
1010
| | | 1 | [2](<_2873. Maximum Value of an Ordered Triplet I.md>) | 3 | 4 | 5 |
1111
| 6 | [7](<_416. Partition Equal Subset Sum.md>) | [8](<_3396. Minimum Number of Operations to Make Elements in Array Distinct.md>) | 9 | 10 | [11](<_2843. Count Symmetric Integers.md>) | 12 |
12-
| [13](<_1922. Count Good Numbers.md>) | [14](<_1534. Count Good Triplets.md>) | 15 | 16 | 17 | 18 | 19 |
12+
| [13](<_1922. Count Good Numbers.md>) | [14](<_1534. Count Good Triplets.md>) | 15 | 16 | 17 | [18](<_38. Count and Say.md>) | 19 |
1313
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
1414
| 27 | 28 | 29 | 30 | | | |
1515

1616

1717

1818
| # | Title | Level | Cats | Solution | Languages | Date Complete |
1919
|-----:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|:---------------|:----------------------------------------------------------------------------------------------------|:-----------------------------|:----------------|
20+
| 38 | [Count and Say](<https://leetcode.com/problems/count-and-say>) | Medium | Daily | [solution](<_38. Count and Say.md>) | py | Apr 18, 2025 |
2021
| 1534 | [Count Good Triplets](<https://leetcode.com/problems/count-good-triplets>) | Easy | Daily | [solution](<_1534. Count Good Triplets.md>) | c, py | Apr 14, 2025 |
2122
| 1922 | [Count Good Numbers](<https://leetcode.com/problems/count-good-numbers>) | Medium | Daily | [solution](<_1922. Count Good Numbers.md>) | py | Apr 13, 2025 |
2223
| 2843 | [ Count Symmetric Integers](<https://leetcode.com/problems/count-symmetric-integers>) | Easy | Daily | [solution](<_2843. Count Symmetric Integers.md>) | py | Apr 11, 2025 |
@@ -283,7 +284,7 @@ Dates are for the date I completed the question so due to the my time zone and h
283284
|-------------------------------------:|-------------------------------------------:|---------------------------------------------------------------------------------:|-------------------------------------------------------:|-----:|---------------------------------------------:|-----:|
284285
| | | 1 | [2](<_2873. Maximum Value of an Ordered Triplet I.md>) | 3 | 4 | 5 |
285286
| 6 | [7](<_416. Partition Equal Subset Sum.md>) | [8](<_3396. Minimum Number of Operations to Make Elements in Array Distinct.md>) | 9 | 10 | [11](<_2843. Count Symmetric Integers.md>) | 12 |
286-
| [13](<_1922. Count Good Numbers.md>) | [14](<_1534. Count Good Triplets.md>) | 15 | 16 | 17 | 18 | 19 |
287+
| [13](<_1922. Count Good Numbers.md>) | [14](<_1534. Count Good Triplets.md>) | 15 | 16 | 17 | [18](<_38. Count and Say.md>) | 19 |
287288
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
288289
| 27 | 28 | 29 | 30 | | | |
289290

markdowns/Medium.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Medium Questions (403)
1+
# Medium Questions (404)
22

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

@@ -17,6 +17,7 @@
1717
| 24 | [Swap Nodes in Pairs](<https://leetcode.com/problems/swap-nodes-in-pairs>) | Medium | | [solution](<_24. Swap Nodes in Pairs.md>) | c | Jun 07, 2024 |
1818
| 33 | [Search in Rotated Sorted Array](<https://leetcode.com/problems/search-in-rotated-sorted-array>) | Medium | B75, N150 | [solution](<_33. Search in Rotated Sorted Array.md>) | py | Dec 17, 2024 |
1919
| 36 | [Valid Sudoku](<https://leetcode.com/problems/valid-sudoku>) | Medium | N150 | [solution](<_36. Valid Sudoku.md>) | py | Jun 13, 2024 |
20+
| 38 | [Count and Say](<https://leetcode.com/problems/count-and-say>) | Medium | Daily | [solution](<_38. Count and Say.md>) | py | Apr 18, 2025 |
2021
| 39 | [Combination Sum](<https://leetcode.com/problems/combination-sum>) | Medium | B75, N150 | [solution](<_39. Combination Sum.md>) | py | Jul 16, 2024 |
2122
| 40 | [Combination Sum II](<https://leetcode.com/problems/combination-sum-ii>) | Medium | Daily, N150 | [solution](<_40. Combination Sum II.md>) | py | Aug 13, 2024 |
2223
| 46 | [Permutations](<https://leetcode.com/problems/permutations>) | Medium | N150 | [solution](<_46. Permutations.md>) | py | Jun 07, 2024 |

markdowns/Questions_By_Code_Length.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ Calculations are based on the code files's byte sizes.
252252
| 3064 | [Guess the Number Using Bitwise Questions I](<https://leetcode.com/problems/guess-the-number-using-bitwise-questions-i>) | Medium | | [solution](<_3064. Guess the Number Using Bitwise Questions I.md>) | c, py | Jun 06, 2024 |
253253
| 347 | [Top K Frequent Elements](<https://leetcode.com/problems/top-k-frequent-elements>) | Medium | B75, N150 | [solution](<_347. Top K Frequent Elements.md>) | py | Jun 13, 2024 |
254254
| 1315 | [Sum of Nodes with Even-Valued Grandparent](<https://leetcode.com/problems/sum-of-nodes-with-even-valued-grandparent>) | Medium | | [solution](<_1315. Sum of Nodes with Even-Valued Grandparent.md>) | py | Jun 12, 2024 |
255+
| 38 | [Count and Say](<https://leetcode.com/problems/count-and-say>) | Medium | Daily | [solution](<_38. Count and Say.md>) | py | Apr 18, 2025 |
255256
| 325 | [Maximum Size Subarray Sum Equals k](<https://leetcode.com/problems/maximum-size-subarray-sum-equals-k>) | Medium | Weekly Premium | [solution](<_325. Maximum Size Subarray Sum Equals k.md>) | py | Apr 15, 2025 |
256257
| 2671 | [Frequency Tracker](<https://leetcode.com/problems/frequency-tracker>) | Medium | | [solution](<_2671. Frequency Tracker.md>) | py | Jun 28, 2024 |
257258
| 23 | [Merge k Sorted Lists](<https://leetcode.com/problems/merge-k-sorted-lists>) | Hard | B75, N150 | [solution](<_23. Merge k Sorted Lists.md>) | py | Jun 17, 2024 |

markdowns/Questions_By_Recent.md

Lines changed: 1 addition & 0 deletions
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+
| 38 | [Count and Say](<https://leetcode.com/problems/count-and-say>) | Medium | Daily | [solution](<_38. Count and Say.md>) | py | Apr 18, 2025 |
910
| 325 | [Maximum Size Subarray Sum Equals k](<https://leetcode.com/problems/maximum-size-subarray-sum-equals-k>) | Medium | Weekly Premium | [solution](<_325. Maximum Size Subarray Sum Equals k.md>) | py | Apr 15, 2025 |
1011
| 1534 | [Count Good Triplets](<https://leetcode.com/problems/count-good-triplets>) | Easy | Daily | [solution](<_1534. Count Good Triplets.md>) | c, py | Apr 14, 2025 |
1112
| 1922 | [Count Good Numbers](<https://leetcode.com/problems/count-good-numbers>) | Medium | Daily | [solution](<_1922. Count Good Numbers.md>) | py | Apr 13, 2025 |

markdowns/Topics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
------
66

77
- [Array](<by_topic/Array.md>) (308 completed)
8-
- [String](<by_topic/String.md>) (146 completed)
8+
- [String](<by_topic/String.md>) (147 completed)
99
- [Hash Table](<by_topic/Hash Table.md>) (140 completed)
1010
- [Depth-First Search](<by_topic/Depth-First Search.md>) (104 completed)
1111
- [Tree](<by_topic/Tree.md>) (91 completed)

markdowns/_38. Count and Say.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# 38. [Count and Say](<https://leetcode.com/problems/count-and-say>)
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 : April 18, 2025*
10+
>
11+
> *Last updated : April 18, 2025*
12+
13+
------
14+
15+
> **Related Topics** : **[String](<by_topic/String.md>)**
16+
>
17+
> **Acceptance Rate** : **58.2 %**
18+
19+
------
20+
21+
## Solutions
22+
23+
- [m38 v1 recursive.py](<../my-submissions/m38 v1 recursive.py>)
24+
- [m38 v2 iterative.py](<../my-submissions/m38 v2 iterative.py>)
25+
### Python
26+
#### [m38 v1 recursive.py](<../my-submissions/m38 v1 recursive.py>)
27+
```Python
28+
class Solution:
29+
def countAndSay(self, n: int) -> str:
30+
if n == 1 :
31+
return '1'
32+
33+
n_min_1 = self.countAndSay(n - 1)
34+
output = []
35+
36+
prev, cnt = None, 0
37+
for c in n_min_1 + "#" : # '#' acts as a delimiter
38+
if c == prev : # to append the final block
39+
cnt += 1
40+
else :
41+
if prev is not None :
42+
output.append(str(cnt))
43+
output.append(prev)
44+
prev, cnt = c, 1
45+
46+
return ''.join(output)
47+
```
48+
49+
#### [m38 v2 iterative.py](<../my-submissions/m38 v2 iterative.py>)
50+
```Python
51+
class Solution:
52+
def countAndSay(self, n: int) -> str:
53+
output = "1"
54+
for _ in repeat(None, n - 1) :
55+
curr, output = output, []
56+
prev, cnt = None, 0
57+
for c in curr + "#" :
58+
if c == prev :
59+
cnt += 1
60+
continue
61+
if prev is not None :
62+
output.extend([str(cnt), prev])
63+
prev, cnt = c, 1
64+
output = ''.join(output)
65+
return output
66+
```
67+

0 commit comments

Comments
 (0)