@scurrlin/stencil 1.23.8 → 1.24.0

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.
Files changed (2) hide show
  1. package/README.md +27 -49
  2. 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 207 "Course Schedule":
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 209 "Minimum Size Subarray Sum":
20
20
 
21
21
  ## Example
22
22
 
@@ -24,62 +24,40 @@ Solution
24
24
 
25
25
  ```python
26
26
  class Solution:
27
- def canFinish(self, numCourses: int, prerequisites: List[List[int]]) -> bool:
28
- preMap = {i: [] for i in range(numCourses)}
29
-
30
- for crs, pre in prerequisites:
31
- preMap[crs].append(pre)
32
-
33
- visiting = set()
34
-
35
- def dfs(crs):
36
- if crs in visiting:
37
- return False
38
- if preMap[crs] == []:
39
- return True
40
- visiting.add(crs)
41
- for pre in preMap[crs]:
42
- if not dfs(pre):
43
- return False
44
- visiting.remove(crs)
45
- preMap[crs] = []
46
- return True
27
+ def minSubArrayLen(self, target: int, nums: List[int]) -> int:
28
+ min_len = float("inf")
29
+ left, curr_sum = 0, 0
30
+
31
+ for right in range(len(nums)):
32
+ curr_sum += nums[right]
33
+
34
+ while curr_sum >= target:
35
+ if right - left + 1 < min_len:
36
+ min_len = right - left + 1
37
+ curr_sum -= nums[left]
38
+ left += 1
47
39
 
48
- for c in range(numCourses):
49
- if not dfs(c):
50
- return False
51
- return True
40
+ return min_len if min_len != float("inf") else 0
52
41
  ```
53
42
 
54
43
  Solution with Stencil
55
44
 
56
45
  ```python
57
46
  c S:
58
- d c(s, n: i, p: L[L[i]]) -> b:
59
- p = {i: [] f i i r(n)}
60
-
61
- f c, p i p:
62
- p[c].a(p)
63
-
64
- v = s()
65
-
66
- d d(c):
67
- i c i v:
68
- r F
69
- i p[c] == []:
70
- r T
71
- v.a(c)
72
- f p i p[c]:
73
- i n d(p):
74
- r F
75
- v.r(c)
76
- p[c] = []
77
- r T
47
+ d m(s, t: i, n: L[i]) -> i:
48
+ m_l = f("i")
49
+ l, c_s = 0, 0
50
+
51
+ f r i r(l(n)):
52
+ c_s += n[r]
53
+
54
+ w c_s >= t:
55
+ i r - l + 1 < m_l:
56
+ m_l = r - l + 1
57
+ c_s -= n[l]
58
+ l += 1
78
59
 
79
- f c i r(n):
80
- i n d(c):
81
- r F
82
- r T
60
+ r m_l i m_l != f("i") e 0
83
61
  ```
84
62
 
85
63
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.23.8",
3
+ "version": "1.24.0",
4
4
  "description": "A memorization tool that strips code down to first letters and punctuation only.",
5
5
  "main": "src/index.js",
6
6
  "bin": {