Skip to content
This repository was archived by the owner on Aug 4, 2025. It is now read-only.

Commit 454f989

Browse files
Update README.md
1 parent 7a42c72 commit 454f989

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

linked_lists/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
```python
1010
class Node:
11-
def __init__(self, val=0, next=None):
11+
12+
def __init__(self, val, next=None):
1213
self.val = val
1314
self.next = next
1415
```
@@ -52,6 +53,8 @@ class Node:
5253

5354
### detecting cycles
5455

56+
<br>
57+
5558
```python
5659
def has_cycle(head) -> bool:
5760

@@ -72,6 +75,8 @@ def has_cycle(head) -> bool:
7275
return True
7376
```
7477

78+
<br>
79+
7580
----
7681

7782
### reversing the list
@@ -126,7 +131,6 @@ def delete_node_without_head(node):
126131
* however, if the node to be deleted is in the head of the list, the best way is to use a sentinel node. sentinel nodes are widely used in trees and linked lists as pseudo-heads, pseudo-tails, markers of level end, etc. they are purely functional and usually do not hold any data. their main purpose is to standardize the process (by making the list never empty or headless).
127132

128133

129-
130134
<br>
131135

132136
```python
@@ -203,6 +207,8 @@ def remove_kth_node(self, head, n):
203207

204208
### swap every two nodes
205209

210+
<br>
211+
206212
```python
207213
def swap_pairs(head):
208214

@@ -218,6 +224,7 @@ def swap_pairs(head):
218224
return second_node
219225
```
220226

227+
<br>
221228

222229
----
223230

0 commit comments

Comments
 (0)