@scurrlin/stencil 1.11.2 → 1.11.3

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 +53 -23
  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 75 "Sort Colors":
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 76 "Minimum Window Substring":
20
20
 
21
21
  ## Example
22
22
 
@@ -24,34 +24,64 @@ Solution
24
24
 
25
25
  ```python
26
26
  class Solution:
27
- def sortColors(self, nums: List[int]) -> None:
28
- count = {}
29
- for i in range(len(nums)):
30
- count[nums[i]] = count.get(nums[i], 0) + 1
31
-
32
- idx = 0
33
-
34
- for color in range(3):
35
- freq = count.get(color, 0)
36
- nums[idx : idx + freq] = [color] * freq
37
- idx += freq
27
+ def minWindow(self, s: str, t: str) -> str:
28
+ if len(s) < len(t):
29
+ return ""
30
+ countT, window = {}, {}
31
+ for c in t:
32
+ countT[c] = 1 + countT.get(c, 0)
33
+
34
+ have, need = 0, len(countT)
35
+ res, resLen = [-1, -1], float("infinity")
36
+ l = 0
37
+
38
+ for r in range(len(s)):
39
+ c = s[r]
40
+ window[c] = 1 + window.get(c, 0)
41
+ if c in countT and window[c] == countT[c]:
42
+ have += 1
43
+ while have == need:
44
+ if (r - l + 1) < resLen:
45
+ res = [l, r]
46
+ resLen = r - l + 1
47
+ window[s[l]] -= 1
48
+ if s[l] in countT and window[s[l]] < countT[s[l]]:
49
+ have -= 1
50
+ l += 1
51
+ l, r = res
52
+ return s[l : r + 1] if resLen != float("infinity") else ""
38
53
  ```
39
54
 
40
55
  Solution with Stencil
41
56
 
42
57
  ```python
43
58
  c S:
44
- d s(s, n: L[i]) -> N:
45
- c = {}
46
- f i i r(l(n)):
47
- c[n[i]] = c.g(n[i], 0) + 1
48
-
49
- i = 0
50
-
51
- f c i r(3):
52
- f = c.g(c, 0)
53
- n[i : i + f] = [c] * f
54
- i += f
59
+ d m(s, s: s, t: s) -> s:
60
+ i l(s) < l(t):
61
+ r ""
62
+ c, w = {}, {}
63
+ f c i t:
64
+ c[c] = 1 + c.g(c, 0)
65
+
66
+ h, n = 0, l(c)
67
+ r, r = [-1, -1], f("i")
68
+ l = 0
69
+
70
+ f r i r(l(s)):
71
+ c = s[r]
72
+ w[c] = 1 + w.g(c, 0)
73
+ i c i c a w[c] == c[c]:
74
+ h += 1
75
+ w h == n:
76
+ i (r - l + 1) < r:
77
+ r = [l, r]
78
+ r = r - l + 1
79
+ w[s[l]] -= 1
80
+ i s[l] i c a w[s[l]] < c[s[l]]:
81
+ h -= 1
82
+ l += 1
83
+ l, r = r
84
+ r s[l : r + 1] i r != f("i") e ""
55
85
  ```
56
86
 
57
87
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.11.2",
3
+ "version": "1.11.3",
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": {