Skip to content

Commit 0418d10

Browse files
committed
add space complexity
1 parent 9395f51 commit 0418d10

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

posts/palindrome-linked-list/index.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,12 @@ <h2 id="thought-process">Thought Process</h2>
235235
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">return</span> <span style="color:#66d9ef">True</span>
236236
</span></span></code></pre></div><h2 id="timespace-complexity">Time/Space Complexity</h2>
237237
<ul>
238-
<li>Time: \( O(n) \) since \( O(n) \) to find the mid + \( O(n) \) to use two-pointer technique to reverse the second-half of the linked list</li>
238+
<li>
239+
<p>Time: \( O(n) \) since \( O(n) \) to find the mid + \( O(n) \) to use two-pointer technique to reverse the second-half of the linked list</p>
240+
</li>
241+
<li>
242+
<p>Space: \( O(1) \) since we are not using any extra space, just pointers</p>
243+
</li>
239244
</ul>
240245
<h2 id="related-problemshow-do-you-feel-about-this-question">Related Problems/How do you feel about this question?</h2>
241246

0 commit comments

Comments
 (0)