feat(528-swapping-nodes-in-a-ll): add py3 optimal solution
This commit is contained in:
14
notes/linked_lists.md
Normal file
14
notes/linked_lists.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
category: ds
|
||||
title: Linked Lists
|
||||
---
|
||||
|
||||
# Linked Lists
|
||||
|
||||
## Finding nth node from beginning and nth node from end
|
||||
|
||||
Use two pointer approach to avoid extra space. Initialize the `kth_node_from_end` pointer when the `tmp` pointer reaches `kth` node and keep incrementing from there on.
|
||||
|
||||
### Related problems
|
||||
|
||||
- https://leetcode.com/problems/swapping-nodes-in-a-linked-list
|
||||
Reference in New Issue
Block a user