@scurrlin/stencil 1.4.7 → 1.4.8

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 +61 -37
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -14,7 +14,7 @@ Whether you are studying for technical interviews, or just starting your coding
14
14
 
15
15
  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.
16
16
 
17
- 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 22 "Generate Parentheses":
17
+ 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 23 "Merge K Sorted Lists":
18
18
 
19
19
  ## Example
20
20
 
@@ -22,48 +22,72 @@ Solution
22
22
 
23
23
  ```python
24
24
  class Solution:
25
- def generateParenthesis(self, n: int) -> List[str]:
26
- stack = []
27
- res = []
28
-
29
- def backtrack(openN, closedN):
30
- if openN == closedN == n:
31
- res.append("".join(stack))
32
- return
33
- if openN < n:
34
- stack.append("(")
35
- backtrack(openN + 1, closedN)
36
- stack.pop()
37
- if closedN < openN:
38
- stack.append(")")
39
- backtrack(openN, closedN + 1)
40
- stack.pop()
41
- backtrack(0, 0)
42
- return res
25
+ def mergeKLists(self, lists: List[ListNode]) -> ListNode:
26
+ if not lists or len(lists) == 0:
27
+ return None
28
+
29
+ while len(lists) > 1:
30
+ mergedLists = []
31
+ for i in range(0, len(lists), 2):
32
+ l1 = lists[i]
33
+ l2 = lists[i + 1] if (i + 1) < len(lists) else None
34
+ mergedLists.append(self.mergeList(l1, l2))
35
+ lists = mergedLists
36
+ return lists[0]
37
+
38
+ def mergeList(self, l1, l2):
39
+ dummy = ListNode()
40
+ tail = dummy
41
+
42
+ while l1 and l2:
43
+ if l1.val < l2.val:
44
+ tail.next = l1
45
+ l1 = l1.next
46
+ else:
47
+ tail.next = l2
48
+ l2 = l2.next
49
+ tail = tail.next
50
+ if l1:
51
+ tail.next = l1
52
+ if l2:
53
+ tail.next = l2
54
+ return dummy.next
43
55
  ```
44
56
 
45
57
  Solution with Stencil
46
58
 
47
59
  ```python
48
60
  c S:
49
- d g(s, n: i) -> L[s]:
50
- s = []
51
- r = []
52
-
53
- d b(o, c):
54
- i o == c == n:
55
- r.a("".j(s))
56
- r
57
- i o < n:
58
- s.a("(")
59
- b(o + 1, c)
60
- s.p()
61
- i c < o:
62
- s.a(")")
63
- b(o, c + 1)
64
- s.p()
65
- b(0, 0)
66
- r r
61
+ d m(s, l: L[L]) -> L:
62
+ i n l o l(l) == 0:
63
+ r N
64
+
65
+ w l(l) > 1:
66
+ m = []
67
+ f i i r(0, l(l), 2):
68
+ l = l[i]
69
+ l = l[i + 1] i (i + 1) < l(l) e N
70
+ m.a(s.m(l, l))
71
+ l = m
72
+ r l[0]
73
+
74
+ d m(s, l, l):
75
+ d = L()
76
+ t = d
77
+
78
+ w l a l:
79
+ i l.v < l.v:
80
+ t.n = l
81
+ l = l.n
82
+ e:
83
+ t.n = l
84
+ l = l.n
85
+ t = t.n
86
+ i l:
87
+ t.n = l
88
+ i l:
89
+ t.n = l
90
+ r d.n
67
91
  ```
68
92
 
69
93
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
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": {