Swap Nodes in A Linked List Without Swapping Data
Swap Nodes in A Linked List Without Swapping Data
class LinkedList(object):
def __init__(self):
self.head = None
# head of list
class Node(object):
def __init__(self, d):
self.data = d
self.next = None
--------------------------------------------------
OUTPUT
------------------------------------------------
Linked list before calling swapNodes()
1
2
3
4
5
6
7