Skip to content

Commit 1b3788b

Browse files
committed
Additional questions
1 parent 8f90eda commit 1b3788b

28 files changed

+350
-30
lines changed

README.md

+6-2
Large diffs are not rendered by default.

markdowns/Questions_By_Code_Length.md

+4
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ Calculations are based on the code files's byte sizes.
205205
| 1448 | [Count Good Nodes in Binary Tree](<https://leetcode.com/problems/count-good-nodes-in-binary-tree>) | Medium | N150 | [solution](<_1448. Count Good Nodes in Binary Tree.md>) | java | Jul 04, 2024 |
206206
| 817 | [Linked List Components](<https://leetcode.com/problems/linked-list-components>) | Medium | | [solution](<_817. Linked List Components.md>) | java | Jul 04, 2024 |
207207
| 2013 | [Detect Squares](<https://leetcode.com/problems/detect-squares>) | Medium | N150 | [solution](<_2013. Detect Squares.md>) | py | Jun 28, 2024 |
208+
| 1457 | [Pseudo-Palindromic Paths in a Binary Tree](<https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree>) | Medium | | [solution](<_1457. Pseudo-Palindromic Paths in a Binary Tree.md>) | py | Jul 05, 2024 |
208209
| 3169 | w contest 400 - q2 | Medium | Contest | [solution](<_3169. w contest 400 - q.md>) | py | Jun 01, 2024 |
209210
| 173 | [Binary Search Tree Iterator](<https://leetcode.com/problems/binary-search-tree-iterator>) | Medium | | [solution](<_173. Binary Search Tree Iterator.md>) | py | Jun 26, 2024 |
210211
| 502 | [IPO](<https://leetcode.com/problems/ipo>) | Hard | Daily | [solution](<_502. IPO.md>) | py | Jun 14, 2024 |
@@ -273,6 +274,7 @@ Calculations are based on the code files's byte sizes.
273274
| 3 | [Longest Substring Without Repeating Characters](<https://leetcode.com/problems/longest-substring-without-repeating-characters>) | Medium | N150, B75 | [solution](<_3. Longest Substring Without Repeating Characters.md>) | java | May 22, 2024 |
274275
| 1052 | [Grumpy Bookstore Owner](<https://leetcode.com/problems/grumpy-bookstore-owner>) | Medium | Daily | [solution](<_1052. Grumpy Bookstore Owner.md>) | py | Jun 20, 2024 |
275276
| 647 | [Palindromic Substrings](<https://leetcode.com/problems/palindromic-substrings>) | Medium | N150, B75 | [solution](<_647. Palindromic Substrings.md>) | py | Jul 04, 2024 |
277+
| 540 | [Single Element in a Sorted Array](<https://leetcode.com/problems/single-element-in-a-sorted-array>) | Medium | | [solution](<_540. Single Element in a Sorted Array.md>) | py | Jul 05, 2024 |
276278
| 2816 | [Double a Number Represented as a Linked List](<https://leetcode.com/problems/double-a-number-represented-as-a-linked-list>) | Medium | | [solution](<_2816. Double a Number Represented as a Linked List.md>) | c | Jul 04, 2024 |
277279
| 1502 | [Can Make Arithmetic Progression From Sequence](<https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence>) | Easy | | [solution](<_1502. Can Make Arithmetic Progression From Sequence.md>) | c, py | Jun 04, 2024 |
278280
| 70 | [Climbing Stairs](<https://leetcode.com/problems/climbing-stairs>) | Easy | N150, B75 | [solution](<_70. Climbing Stairs.md>) | py | May 22, 2024 |
@@ -307,6 +309,7 @@ Calculations are based on the code files's byte sizes.
307309
| 3185 | w contest 402 - q2 | Medium | Contest | [solution](<_3185. w contest 402 - q.md>) | py | Jun 15, 2024 |
308310
| 2352 | [Equal Row and Column Pairs](<https://leetcode.com/problems/equal-row-and-column-pairs>) | Medium | | [solution](<_2352. Equal Row and Column Pairs.md>) | py | Jun 26, 2024 |
309311
| 345 | [Reverse Vowels of a String](<https://leetcode.com/problems/reverse-vowels-of-a-string>) | Easy | | [solution](<_345. Reverse Vowels of a String.md>) | py | May 23, 2024 |
312+
| 503 | [Next Greater Element II](<https://leetcode.com/problems/next-greater-element-ii>) | Medium | | [solution](<_503. Next Greater Element II.md>) | py | Jul 05, 2024 |
310313
| 344 | [Reverse String](<https://leetcode.com/problems/reverse-string>) | Easy | Daily | [solution](<_344. Reverse String.md>) | java, py | Jun 01, 2024 |
311314
| 2221 | [Find Triangular Sum of an Array](<https://leetcode.com/problems/find-triangular-sum-of-an-array>) | Medium | | [solution](<_2221. Find Triangular Sum of an Array.md>) | c, java | Jun 26, 2024 |
312315
| 56 | [Merge Intervals](<https://leetcode.com/problems/merge-intervals>) | Medium | N150, B75 | [solution](<_56. Merge Intervals.md>) | py | Jun 18, 2024 |
@@ -360,6 +363,7 @@ Calculations are based on the code files's byte sizes.
360363
| 3074 | [Apple Redistribution into Boxes](<https://leetcode.com/problems/apple-redistribution-into-boxes>) | Easy | | [solution](<_3074. Apple Redistribution into Boxes.md>) | py | May 23, 2024 |
361364
| 9 | [Palindrome Number](<https://leetcode.com/problems/palindrome-number>) | Easy | | [solution](<_9. Palindrome Number.md>) | java | May 22, 2024 |
362365
| 1030 | [Matrix Cells in Distance Order](<https://leetcode.com/problems/matrix-cells-in-distance-order>) | Easy | | [solution](<_1030. Matrix Cells in Distance Order.md>) | py | Jun 03, 2024 |
366+
| 2268 | [Minimum Number of Keypresses](<https://leetcode.com/problems/minimum-number-of-keypresses>) | Medium | | [solution](<_2268. Minimum Number of Keypresses.md>) | py | Jul 05, 2024 |
363367
| 184 | [Department Highest Salary](<https://leetcode.com/problems/department-highest-salary>) | Medium | | [solution](<_184. Department Highest Salary.md>) | sql | Jun 07, 2024 |
364368
| 2011 | [Final Value of Variable After Performing Operations](<https://leetcode.com/problems/final-value-of-variable-after-performing-operations>) | Easy | | [solution](<_2011. Final Value of Variable After Performing Operations.md>) | c | Jun 03, 2024 |
365369
| 2678 | [Number of Senior Citizens](<https://leetcode.com/problems/number-of-senior-citizens>) | Easy | | [solution](<_2678. Number of Senior Citizens.md>) | java | May 22, 2024 |

markdowns/Questions_By_Recent.md

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

77
| # | Title | Level | Cats | Solution | Languages | Date Complete |
88
|-----:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|:---------------|:---------------------------------------------------------------------------------------------------|:---------------------------------|:----------------|
9+
| 503 | [Next Greater Element II](<https://leetcode.com/problems/next-greater-element-ii>) | Medium | | [solution](<_503. Next Greater Element II.md>) | py | Jul 05, 2024 |
10+
| 2268 | [Minimum Number of Keypresses](<https://leetcode.com/problems/minimum-number-of-keypresses>) | Medium | | [solution](<_2268. Minimum Number of Keypresses.md>) | py | Jul 05, 2024 |
11+
| 540 | [Single Element in a Sorted Array](<https://leetcode.com/problems/single-element-in-a-sorted-array>) | Medium | | [solution](<_540. Single Element in a Sorted Array.md>) | py | Jul 05, 2024 |
12+
| 1457 | [Pseudo-Palindromic Paths in a Binary Tree](<https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree>) | Medium | | [solution](<_1457. Pseudo-Palindromic Paths in a Binary Tree.md>) | py | Jul 05, 2024 |
913
| 919 | [Complete Binary Tree Inserter](<https://leetcode.com/problems/complete-binary-tree-inserter>) | Medium | | [solution](<_919. Complete Binary Tree Inserter.md>) | py | Jul 05, 2024 |
1014
| 1609 | [Even Odd Tree](<https://leetcode.com/problems/even-odd-tree>) | Medium | | [solution](<_1609. Even Odd Tree.md>) | py | Jul 05, 2024 |
1115
| 1372 | [Longest ZigZag Path in a Binary Tree](<https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree>) | Medium | | [solution](<_1372. Longest ZigZag Path in a Binary Tree.md>) | py | Jul 05, 2024 |

markdowns/Topics.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,37 @@
44

55
------
66

7-
- [Array](<by_topic/Array.md>) (174 completed)
8-
- [String](<by_topic/String.md>) (85 completed)
9-
- [Hash Table](<by_topic/Hash Table.md>) (84 completed)
10-
- [Depth-First Search](<by_topic/Depth-First Search.md>) (67 completed)
11-
- [Tree](<by_topic/Tree.md>) (65 completed)
12-
- [Binary Tree](<by_topic/Binary Tree.md>) (60 completed)
13-
- [Sorting](<by_topic/Sorting.md>) (54 completed)
14-
- [Breadth-First Search](<by_topic/Breadth-First Search.md>) (46 completed)
7+
- [Array](<by_topic/Array.md>) (176 completed)
8+
- [String](<by_topic/String.md>) (86 completed)
9+
- [Hash Table](<by_topic/Hash Table.md>) (85 completed)
10+
- [Depth-First Search](<by_topic/Depth-First Search.md>) (68 completed)
11+
- [Tree](<by_topic/Tree.md>) (66 completed)
12+
- [Binary Tree](<by_topic/Binary Tree.md>) (61 completed)
13+
- [Sorting](<by_topic/Sorting.md>) (55 completed)
14+
- [Breadth-First Search](<by_topic/Breadth-First Search.md>) (47 completed)
1515
- [Math](<by_topic/Math.md>) (46 completed)
1616
- [Two Pointers](<by_topic/Two Pointers.md>) (43 completed)
1717
- [Linked List](<by_topic/Linked List.md>) (38 completed)
18-
- [Stack](<by_topic/Stack.md>) (34 completed)
18+
- [Stack](<by_topic/Stack.md>) (35 completed)
19+
- [Greedy](<by_topic/Greedy.md>) (31 completed)
1920
- [Matrix](<by_topic/Matrix.md>) (30 completed)
20-
- [Greedy](<by_topic/Greedy.md>) (30 completed)
2121
- [Simulation](<by_topic/Simulation.md>) (25 completed)
22-
- [Bit Manipulation](<by_topic/Bit Manipulation.md>) (23 completed)
22+
- [Bit Manipulation](<by_topic/Bit Manipulation.md>) (24 completed)
2323
- [Dynamic Programming](<by_topic/Dynamic Programming.md>) (20 completed)
2424
- [Design](<by_topic/Design.md>) (20 completed)
2525
- [Database](<by_topic/Database.md>) (18 completed)
26+
- [Binary Search](<by_topic/Binary Search.md>) (18 completed)
2627
- [Trie](<by_topic/Trie.md>) (18 completed)
27-
- [Binary Search](<by_topic/Binary Search.md>) (17 completed)
2828
- [Heap (Priority Queue)](<by_topic/Heap (Priority Queue).md>) (16 completed)
29+
- [Counting](<by_topic/Counting.md>) (14 completed)
2930
- [Recursion](<by_topic/Recursion.md>) (14 completed)
3031
- [Backtracking](<by_topic/Backtracking.md>) (13 completed)
31-
- [Counting](<by_topic/Counting.md>) (13 completed)
3232
- [Binary Search Tree](<by_topic/Binary Search Tree.md>) (13 completed)
3333
- [Prefix Sum](<by_topic/Prefix Sum.md>) (10 completed)
3434
- [Sliding Window](<by_topic/Sliding Window.md>) (10 completed)
35+
- [Monotonic Stack](<by_topic/Monotonic Stack.md>) (9 completed)
3536
- [Queue](<by_topic/Queue.md>) (8 completed)
3637
- [Union Find](<by_topic/Union Find.md>) (8 completed)
37-
- [Monotonic Stack](<by_topic/Monotonic Stack.md>) (8 completed)
3838
- [Divide and Conquer](<by_topic/Divide and Conquer.md>) (6 completed)
3939
- [String Matching](<by_topic/String Matching.md>) (6 completed)
4040
- [Graph](<by_topic/Graph.md>) (6 completed)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# 1457. [Pseudo-Palindromic Paths in a Binary Tree](<https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree>)
2+
3+
*[Back to top](<../README.md>)*
4+
5+
------
6+
7+
> *First completed : July 05, 2024*
8+
>
9+
> *Last updated : July 05, 2024*
10+
11+
12+
------
13+
14+
> **Related Topics** : **[Bit Manipulation](<by_topic/Bit Manipulation.md>), [Tree](<by_topic/Tree.md>), [Depth-First Search](<by_topic/Depth-First Search.md>), [Breadth-First Search](<by_topic/Breadth-First Search.md>), [Binary Tree](<by_topic/Binary Tree.md>)**
15+
>
16+
> **Acceptance Rate** : **68.383 %**
17+
18+
19+
------
20+
21+
*To see the question prompt, click the title.*
22+
23+
## Solutions
24+
25+
- [m1457.py](<../my-submissions/m1457.py>)
26+
### Python
27+
#### [m1457.py](<../my-submissions/m1457.py>)
28+
```Python
29+
# Definition for a binary tree node.
30+
# class TreeNode:
31+
# def __init__(self, val=0, left=None, right=None):
32+
# self.val = val
33+
# self.left = left
34+
# self.right = right
35+
class Solution:
36+
def pseudoPalindromicPaths (self, root: Optional[TreeNode]) -> int:
37+
def dfs(curr: Optional[TreeNode], vals: List[bool] = [False] * 10) -> int :
38+
if not curr :
39+
return 0
40+
41+
vals[curr.val] = not vals[curr.val]
42+
43+
if not curr.left and not curr.right :
44+
oddCnt = vals.count(True)
45+
vals[curr.val] = not vals[curr.val]
46+
if oddCnt <= 1 :
47+
return 1
48+
return 0
49+
50+
output = dfs(curr.left) + dfs(curr.right)
51+
vals[curr.val] = not vals[curr.val]
52+
return output
53+
54+
return dfs(root)
55+
```
56+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# 2268. [Minimum Number of Keypresses](<https://leetcode.com/problems/minimum-number-of-keypresses>)
2+
3+
*[Back to top](<../README.md>)*
4+
5+
------
6+
7+
> *First completed : July 05, 2024*
8+
>
9+
> *Last updated : July 05, 2024*
10+
11+
12+
------
13+
14+
> **Related Topics** : **[Hash Table](<by_topic/Hash Table.md>), [String](<by_topic/String.md>), [Greedy](<by_topic/Greedy.md>), [Sorting](<by_topic/Sorting.md>), [Counting](<by_topic/Counting.md>)**
15+
>
16+
> **Acceptance Rate** : **70.997 %**
17+
18+
19+
------
20+
21+
*To see the question prompt, click the title.*
22+
23+
> This results in an $O(n)$ despite the sorting due to it only sorting
24+
> the counts of each letter meaning it sorts at most 26 values.
25+
26+
------
27+
28+
## Solutions
29+
30+
- [m2268.py](<../my-submissions/m2268.py>)
31+
### Python
32+
#### [m2268.py](<../my-submissions/m2268.py>)
33+
```Python
34+
class Solution:
35+
def minimumKeypresses(self, s: str) -> int:
36+
output = 0
37+
cnt = Counter(s)
38+
mapped = 9
39+
40+
for v in sorted(cnt.values(), reverse=True) :
41+
cost = mapped // 9
42+
output += cost * v
43+
mapped += 1
44+
45+
return output
46+
```
47+

0 commit comments

Comments
 (0)