@scurrlin/stencil 1.31.5 → 1.31.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Whether you are studying for technical interviews, or just starting your coding
|
|
|
16
16
|
|
|
17
17
|
Most people when they attempt to memorize something study the full text and then attempt to regurgitate it on a blank page. Shocking, I know... but what if there was a step in between? What if memorization and pattern recognition weren't all or nothing games? This is where Stencil comes in.
|
|
18
18
|
|
|
19
|
-
Stencil is a language-agnostic memorization tool that strips code files down to their first letters while preserving spacing, capitalization, and punctuation. The "stencil" of the file is designed to act as a bridge between having something partially memorized and fully memorized. Below is an example of Stencil in action using LeetCode problem
|
|
19
|
+
Stencil is a language-agnostic memorization tool that strips code files down to their first letters while preserving spacing, capitalization, and punctuation. The "stencil" of the file is designed to act as a bridge between having something partially memorized and fully memorized. Below is an example of Stencil in action using LeetCode problem 329 "Longest Increasing Path in a Matrix":
|
|
20
20
|
|
|
21
21
|
## Example
|
|
22
22
|
|
|
@@ -24,32 +24,52 @@ Solution
|
|
|
24
24
|
|
|
25
25
|
```python
|
|
26
26
|
class Solution:
|
|
27
|
-
def
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
def longestIncreasingPath(self, matrix: List[List[int]]) -> int:
|
|
28
|
+
if not matrix or not matrix[0]:
|
|
29
|
+
return 0
|
|
30
|
+
|
|
31
|
+
rows, cols = len(matrix), len(matrix[0])
|
|
32
|
+
dp =[[0] * cols for i in range(rows)]
|
|
33
|
+
def dfs(i, j):
|
|
34
|
+
if not dp[i][j]:
|
|
35
|
+
val = matrix[i][j]
|
|
36
|
+
dp[i][j] = 1 + max(
|
|
37
|
+
dfs(i - 1, j) if i and val > matrix[i - 1][j] else 0,
|
|
38
|
+
dfs(i + 1, j) if i < rows - 1 and val > matrix[i + 1][j] else 0,
|
|
39
|
+
dfs(i, j - 1) if j and val > matrix[i][j - 1] else 0,
|
|
40
|
+
dfs(i, j + 1) if j < cols - 1 and val > matrix[i][j + 1] else 0)
|
|
41
|
+
return dp[i][j]
|
|
42
|
+
|
|
43
|
+
for r in range(rows):
|
|
44
|
+
for c in range(cols):
|
|
45
|
+
dfs(r, c)
|
|
46
|
+
return max(max(x) for x in dp)
|
|
37
47
|
```
|
|
38
48
|
|
|
39
49
|
Solution with Stencil
|
|
40
50
|
|
|
41
51
|
```python
|
|
42
52
|
c S:
|
|
43
|
-
d
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
d l(s, m: L[L[i]]) -> i:
|
|
54
|
+
i n m o n m[0]:
|
|
55
|
+
r 0
|
|
56
|
+
|
|
57
|
+
r, c = l(m), l(m[0])
|
|
58
|
+
d =[[0] * c f i i r(r)]
|
|
59
|
+
d d(i, j):
|
|
60
|
+
i n d[i][j]:
|
|
61
|
+
v = m[i][j]
|
|
62
|
+
d[i][j] = 1 + m(
|
|
63
|
+
d(i - 1, j) i i a v > m[i - 1][j] e 0,
|
|
64
|
+
d(i + 1, j) i i < r - 1 a v > m[i + 1][j] e 0,
|
|
65
|
+
d(i, j - 1) i j a v > m[i][j - 1] e 0,
|
|
66
|
+
d(i, j + 1) i j < c - 1 a v > m[i][j + 1] e 0)
|
|
67
|
+
r d[i][j]
|
|
68
|
+
|
|
69
|
+
f r i r(r):
|
|
70
|
+
f c i r(c):
|
|
71
|
+
d(r, c)
|
|
72
|
+
r m(m(x) f x i d)
|
|
53
73
|
```
|
|
54
74
|
|
|
55
75
|
## Local Installation
|