You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-9Lines changed: 31 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,9 +18,11 @@ Output: 3
18
18
Input: s = "(1+(4+5+2)-3)+(6+8)"
19
19
Output: 23
20
20
`
21
-
22
21
<br>
23
22
23
+
24
+
25
+
24
26
## Question 432: All O'one Data Structure
25
27
Design a data structure to store the strings' count with the ability to return the strings with minimum and maximum counts.
26
28
@@ -30,8 +32,19 @@ Implement the AllOne class:
30
32
*`dec(String key)` Decrements the count of the string `key` by `1`. If the count of `key` is `0` after the decrement, remove it from the data structure. It is guaranteed that `key` exists in the data structure before the decrement.
31
33
*`getMaxKey()` Returns one of the keys with the maximal count. If no element exists, return an empty string `""`.
32
34
*`getMinKey()` Returns one of the keys with the minimum count. If no element exists, return an empty string `""`.
35
+
<br>
36
+
33
37
38
+
39
+
40
+
## Question 797: All Paths From Source to Target
41
+
Given a directed acyclic graph (***DAG***) of `n` nodes labeled from `0` to `n - 1`, find all possible paths from node 0 to node n - 1 and return them in ***any order***.
34
42
<br>
43
+
The graph is given as follows: graph[i] is a list of all nodes you can visit from node i (i.e., there is a directed edge from node i to node `graph[i][j]`).
44
+
<br><br><br>
45
+
46
+
47
+
35
48
36
49
## Question 1046: Last Stone Weight
37
50
You are given an array of integers `stones` where `stones[i]` is the weight of the i<sup>th</sup> stone. <br>
@@ -41,21 +54,29 @@ We are playing a game with the stones. On each turn, we choose the ***heaviest t
41
54
42
55
At the end of the game, there is ***at most one*** stone left.<br>
43
56
Return the smallest ***possible weight of the left stone***. If there are no stones left, return `0`.
57
+
<br><br><br>
58
+
59
+
60
+
61
+
62
+
## Question 1162: As Far from Land as Possible
63
+
Given an `n x n grid` containing only values `0` and `1`, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized, and return the distance. If no land or water exists in the grid, return `-1`. <br><br>
64
+
The distance used in this problem is the Manhattan distance: <br>
65
+
The distance between two cells `(x0, y0)` and `(x1, y1)` is `|x0 - x1| + |y0 - y1|`.
66
+
<br><br><br>
67
+
68
+
44
69
45
-
<br>
46
70
47
71
## Question 1496: Path Crossing
48
72
Given a string path, where `path[i] =``N`, `S`, `E` or `W`, each representing moving one unit north, south, east, or west, respectively. You start at the origin `(0, 0)` on a 2D plane and walk on the path specified by path.
49
-
<br>
50
-
Return ***true*** if the path crosses itself at any point, that is, if at any time you are on a location you have previously visited. Return ***false*** otherwise.
73
+
<br><br>
74
+
Return ***true*** if the path crosses itself at any point, that is, if at any time you are on a location you have previously visited. <br>
75
+
Return ***false*** otherwise.
76
+
<br><br><br>
51
77
52
-
<br>
53
78
54
-
## Question 1162: As Far from Land as Possible
55
-
Given an `n x n grid` containing only values `0` and `1`, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized, and return the distance. If no land or water exists in the grid, return `-1`. <br>
56
-
The distance used in this problem is the Manhattan distance: the distance between two cells `(x0, y0)` and `(x1, y1)` is `|x0 - x1| + |y0 - y1|`.
57
79
58
-
<br>
59
80
60
81
## Question 1609: Even Odd Tree
61
82
A binary tree is named Even-Odd if it meets the following conditions: <br>
@@ -64,3 +85,4 @@ A binary tree is named Even-Odd if it meets the following conditions: <br>
64
85
* For every ***odd-indexed level***, all nodes at the level have `even` integer values in ***strictly decreasing*** order (from left to right). <br>
65
86
66
87
Given the `root` of a binary tree, return ***true*** if the binary tree is Even-Odd, otherwise return ***false***.
0 commit comments