Skip to content

Commit ae60cfc

Browse files
authored
Remove comments on kth node solutions
Removed detailed comments about the solutions for finding the kth element from the tail of a singly linked list.
1 parent 5001dda commit ae60cfc

1 file changed

Lines changed: 0 additions & 14 deletions

File tree

src/4_Lists/kth_node.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,6 @@
66
* Find the kth element from the tail (0-indexed) of a singly linked list.
77
* Three solutions are provided:
88
*
9-
* 1. Simple Solution:
10-
* - Traverses the list to store all elements in a vector and then indexes
11-
* from the end.
12-
* - Easy to implement and understand, but uses O(n) extra space.
13-
*
14-
* 2. Optimal (Efficient) Solution:
15-
* - Uses the two-pointer technique: one pointer is moved k steps ahead,
16-
* then both pointers move until the lead pointer reaches the end.
17-
* - Achieves O(n) time and O(1) space complexity.
18-
*
19-
* 3. Alternative Solution:
20-
* - Uses recursion to determine the kth element from the tail.
21-
* - Although elegant, it uses additional stack space due to recursive calls.
22-
*
239
* ASCII Illustration:
2410
*
2511
* Linked List: 1 -> 2 -> 3 -> 4 -> 5

0 commit comments

Comments
 (0)