@scurrlin/stencil 1.19.4 → 1.19.6

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 +25 -37
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -16,56 +16,44 @@ 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 155 "Min Stack":
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 162 "Find Peak Element":
20
20
 
21
21
  ## Example
22
22
 
23
23
  Solution
24
24
 
25
25
  ```python
26
- class MinStack:
27
- def __init__(self):
28
- self.stack = []
29
- self.minStack = []
26
+ class Solution:
27
+ def findPeakElement(self, nums: List[int]) -> int:
28
+ l, r = 0, len(nums) - 1
30
29
 
31
- def push(self, val: int) -> None:
32
- self.stack.append(val)
33
- val = min(val, self.minStack[-1] if self.minStack else val)
34
- self.minStack.append(val)
35
-
36
- def pop(self) -> None:
37
- self.stack.pop()
38
- self.minStack.pop()
39
-
40
- def top(self) -> int:
41
- return self.stack[-1]
42
-
43
- def getMin(self) -> int:
44
- return self.minStack[-1]
30
+ while l <= r:
31
+ m = (r + l) // 2
32
+ if m < len(nums) - 1 and nums[m] < nums[m + 1]:
33
+ l = m + 1
34
+ elif m > 0 and nums[m] < nums[m - 1]:
35
+ r = m - 1
36
+ else:
37
+ break
38
+ return m
45
39
  ```
46
40
 
47
41
  Solution with Stencil
48
42
 
49
43
  ```python
50
- c M:
51
- d __i__(s):
52
- s.s = []
53
- s.m = []
44
+ c S:
45
+ d f(s, n: L[i]) -> i:
46
+ l, r = 0, l(n) - 1
54
47
 
55
- d p(s, v: i) -> N:
56
- s.s.a(v)
57
- v = m(v, s.m[-1] i s.m e v)
58
- s.m.a(v)
59
-
60
- d p(s) -> N:
61
- s.s.p()
62
- s.m.p()
63
-
64
- d t(s) -> i:
65
- r s.s[-1]
66
-
67
- d g(s) -> i:
68
- r s.m[-1]
48
+ w l <= r:
49
+ m = (r + l) // 2
50
+ i m < l(n) - 1 a n[m] < n[m + 1]:
51
+ l = m + 1
52
+ e m > 0 a n[m] < n[m - 1]:
53
+ r = m - 1
54
+ e:
55
+ b
56
+ r m
69
57
  ```
70
58
 
71
59
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.19.4",
3
+ "version": "1.19.6",
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": {