@scurrlin/stencil 1.1.0 → 1.1.2

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 +41 -23
  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 153 "Find Minimum in Rotated Sorted Array":
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 143 "Reorder List":
18
18
 
19
19
  ## Example
20
20
 
@@ -22,36 +22,54 @@ Solution
22
22
 
23
23
  ```python
24
24
  class Solution:
25
- def findMin(self, nums: List[int]) -> int:
26
- start, end = 0, len(nums) - 1
27
- curr_min = float("inf")
25
+ def reorderList(self, head: ListNode) -> None:
26
+ if not head or not head.next:
27
+ return
28
+ slow, fast = head, head.next
28
29
 
29
- while start < end :
30
- mid = start + (end - start)//2
31
- curr_min = min(curr_min, nums[mid])
32
- if nums[mid] > nums[end]:
33
- start = mid + 1
34
- else:
35
- end = mid - 1
36
- return min(curr_min, nums[start])
30
+ while fast and fast.next:
31
+ slow = slow.next
32
+ fast = fast.next.next
33
+ second = slow.next
34
+ prev = slow.next = None
35
+ while second:
36
+ temp = second.next
37
+ second.next = prev
38
+ prev = second
39
+ second = temp
40
+ first, second = head, prev
41
+ while second:
42
+ temp1, temp2 = first.next, second.next
43
+ first.next = second
44
+ second.next = temp1
45
+ first, second = temp1, temp2
37
46
  ```
38
47
 
39
48
  Solution with Stencil
40
49
 
41
50
  ```python
42
51
  c S:
43
- d f(s, n: L[i]) -> i:
44
- s, e = 0, l(n) - 1
45
- c_m = f("i")
52
+ d r(s, h: L) -> N:
53
+ i n h o n h.n:
54
+ r
55
+ s, f = h, h.n
46
56
 
47
- w s < e :
48
- m = s + (e - s)//2
49
- c_m = m(c_m, n[m])
50
- i n[m] > n[e]:
51
- s = m + 1
52
- e:
53
- e = m - 1
54
- r m(c_m, n[s])
57
+ w f a f.n:
58
+ s = s.n
59
+ f = f.n.n
60
+ s = s.n
61
+ p = s.n = N
62
+ w s:
63
+ t = s.n
64
+ s.n = p
65
+ p = s
66
+ s = t
67
+ f, s = h, p
68
+ w s:
69
+ t, t = f.n, s.n
70
+ f.n = s
71
+ s.n = t
72
+ f, s = t, t
55
73
  ```
56
74
 
57
75
  ## Local Installation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scurrlin/stencil",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
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": {