Notion Database
🗣️ How to Be a Strong Hire - Interview Insights
🎯 Problem: Odd-Even Linked List
How to explain it in an interview to show you’re a strong hire:
“To solve this, I used a two-pointer strategy — one for odd-indexed nodes and one for even-indexed nodes. I conceptually treat the linked list like two interleaved sublists — one for all odd nodes and one for even ones.
As I traverse, I rewire the .next pointers to separate these two sequences. The critical insight is understanding that in a linked list, updating .next alone is not enough — I also need to move the tail pointer forward. I call this the ’tail follows head’ principle: once I update odd.next, I must move odd = odd.next so that the tail pointer remains accurate for future rewiring.
After separation, I stitch the end of the odd list to the head of the even list, which I preserved before modification. This keeps the operation in-place with O(1) space and O(n) time.”
🔁 Bonus phrasing:
“I reused the existing node structure instead of allocating new nodes.”
“The key is safe pointer progression — modifying .next and moving the active pointer in tandem.”
“It’s a pointer-surgery problem with clear sequencing logic.”
Binary Tree
topics…
Problems
909. Snakes and Ladders
1[ 0, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 35, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ]
1[
2 0, -1, 15, -1, -1, -1,
3 -1, -1, -1, -1, -1, -1,
4 -1, -1, 35, -1, -1, 13,
5 -1, -1, -1, -1, -1, -1,
6 -1, -1, -1, -1, -1, -1,
7 -1, -1, -1, -1, -1, -1, -1
8]
1=== Start of Loop (Move 1) ===
2Current Queue: Queue { _elements: [ 1 ], _offset: 0 }
3Queue size: 1
4Processing position: 1
5Enqueued: 15 (from position 2)
6Enqueued: 3 (from position 3)
7Enqueued: 4 (from position 4)
8Enqueued: 5 (from position 5)
9Enqueued: 6 (from position 6)
10Enqueued: 7 (from position 7)
11=== End of Loop (Move 1) ===
12
13
14=== Start of Loop (Move 2) ===
15Current Queue: Queue { _elements: [ 15, 3, 4, 5, 6, 7 ], _offset: 0 }
16Queue size: 6
17Processing position: 15
18Enqueued: 16 (from position 16)
19Enqueued: 13 (from position 17)
20Enqueued: 18 (from position 18)
21Enqueued: 19 (from position 19)
22Enqueued: 20 (from position 20)
23Enqueued: 21 (from position 21)
24Processing position: 3
25Visited: 4 (from position 4)
26Visited: 5 (from position 5)
27Visited: 6 (from position 6)
28Visited: 7 (from position 7)
29Enqueued: 8 (from position 8)
30Enqueued: 9 (from position 9)
31Processing position: 4
32Visited: 5 (from position 5)
33Visited: 6 (from position 6)
34Visited: 7 (from position 7)
35Visited: 8 (from position 8)
36Visited: 9 (from position 9)
37Enqueued: 10 (from position 10)
38Processing position: 5
39Visited: 6 (from position 6)
40Visited: 7 (from position 7)
41Visited: 8 (from position 8)
42Visited: 9 (from position 9)
43Visited: 10 (from position 10)
44Enqueued: 11 (from position 11)
45Processing position: 6
46Visited: 7 (from position 7)
47Visited: 8 (from position 8)
48Visited: 9 (from position 9)
49Visited: 10 (from position 10)
50Visited: 11 (from position 11)
51Enqueued: 12 (from position 12)
52Processing position: 7
53Visited: 8 (from position 8)
54Visited: 9 (from position 9)
55Visited: 10 (from position 10)
56Visited: 11 (from position 11)
57Visited: 12 (from position 12)
58Visited: 13 (from position 13)
59=== End of Loop (Move 2) ===
60
61
62=== Start of Loop (Move 3) ===
63Current Queue: Queue {
64 _elements: [
65 15, 3, 4, 5, 6, 7, 16,
66 13, 18, 19, 20, 21, 8, 9,
67 10, 11, 12
68 ],
69 _offset: 6
70}
71Queue size: 11
72Processing position: 16
73Visited: 13 (from position 17)
74Visited: 18 (from position 18)
75Visited: 19 (from position 19)
76Visited: 20 (from position 20)
77Visited: 21 (from position 21)
78Enqueued: 22 (from position 22)
79Processing position: 13
80Enqueued: 35 (from position 14)
81Visited: 15 (from position 15)
82Visited: 16 (from position 16)
83Visited: 13 (from position 17)
84Visited: 18 (from position 18)
85Visited: 19 (from position 19)
86Processing position: 18
87Visited: 19 (from position 19)
88Visited: 20 (from position 20)
89Visited: 21 (from position 21)
90Visited: 22 (from position 22)
91Enqueued: 23 (from position 23)
92Enqueued: 24 (from position 24)
93Processing position: 19
94Visited: 20 (from position 20)
95Visited: 21 (from position 21)
96Visited: 22 (from position 22)
97Visited: 23 (from position 23)
98Visited: 24 (from position 24)
99Enqueued: 25 (from position 25)
100Processing position: 20
101Visited: 21 (from position 21)
102Visited: 22 (from position 22)
103Visited: 23 (from position 23)
104Visited: 24 (from position 24)
105Visited: 25 (from position 25)
106Enqueued: 26 (from position 26)
107Processing position: 21
108Visited: 22 (from position 22)
109Visited: 23 (from position 23)
110Visited: 24 (from position 24)
111Visited: 25 (from position 25)
112Visited: 26 (from position 26)
113Enqueued: 27 (from position 27)
114Processing position: 8
115Visited: 9 (from position 9)
116Visited: 10 (from position 10)
117Visited: 11 (from position 11)
118Visited: 12 (from position 12)
119Visited: 13 (from position 13)
120Visited: 35 (from position 14)
121Processing position: 9
122Visited: 10 (from position 10)
123Visited: 11 (from position 11)
124Visited: 12 (from position 12)
125Visited: 13 (from position 13)
126Visited: 35 (from position 14)
127Visited: 15 (from position 15)
128Processing position: 10
129Visited: 11 (from position 11)
130Visited: 12 (from position 12)
131Visited: 13 (from position 13)
132Visited: 35 (from position 14)
133Visited: 15 (from position 15)
134Visited: 16 (from position 16)
135Processing position: 11
136Visited: 12 (from position 12)
137Visited: 13 (from position 13)
138Visited: 35 (from position 14)
139Visited: 15 (from position 15)
140Visited: 16 (from position 16)
141Visited: 13 (from position 17)
142Processing position: 12
143Visited: 13 (from position 13)
144Visited: 35 (from position 14)
145Visited: 15 (from position 15)
146Visited: 16 (from position 16)
147Visited: 13 (from position 17)
148Visited: 18 (from position 18)
149=== End of Loop (Move 3) ===
150
151
152=== Start of Loop (Move 4) ===
153Current Queue: Queue {
154 _elements: [
155 21, 8, 9, 10, 11, 12,
156 22, 35, 23, 24, 25, 26,
157 27
158 ],
159 _offset: 6
160}
161Queue size: 7
162Processing position: 22
163Visited: 23 (from position 23)
164Visited: 24 (from position 24)
165Visited: 25 (from position 25)
166Visited: 26 (from position 26)
167Visited: 27 (from position 27)
168Enqueued: 28 (from position 28)
169Processing position: 35
170Enqueued: 36 (from position 36)
171Processing position: 23
172Visited: 24 (from position 24)
173Visited: 25 (from position 25)
174Visited: 26 (from position 26)
175Visited: 27 (from position 27)
176Visited: 28 (from position 28)
177Enqueued: 29 (from position 29)
178Processing position: 24
179Visited: 25 (from position 25)
180Visited: 26 (from position 26)
181Visited: 27 (from position 27)
182Visited: 28 (from position 28)
183Visited: 29 (from position 29)
184Enqueued: 30 (from position 30)
185Processing position: 25
186Visited: 26 (from position 26)
187Visited: 27 (from position 27)
188Visited: 28 (from position 28)
189Visited: 29 (from position 29)
190Visited: 30 (from position 30)
191Enqueued: 31 (from position 31)
192Processing position: 26
193Visited: 27 (from position 27)
194Visited: 28 (from position 28)
195Visited: 29 (from position 29)
196Visited: 30 (from position 30)
197Visited: 31 (from position 31)
198Enqueued: 32 (from position 32)
199Processing position: 27
200Visited: 28 (from position 28)
201Visited: 29 (from position 29)
202Visited: 30 (from position 30)
203Visited: 31 (from position 31)
204Visited: 32 (from position 32)
205Enqueued: 33 (from position 33)
206=== End of Loop (Move 4) ===
207
208
209=== Start of Loop (Move 5) ===
210Current Queue: Queue {
211 _elements: [
212 28, 36, 29, 30,
213 31, 32, 33
214 ],
215 _offset: 0
216}
217Queue size: 7
218Processing position: 28
219Visited: 29 (from position 29)
220Visited: 30 (from position 30)
221Visited: 31 (from position 31)
222Visited: 32 (from position 32)
223Visited: 33 (from position 33)
224Enqueued: 34 (from position 34)
225Processing position: 36
226Reached the end at position 36! Total moves: 4