Skip to content

Instantly share code, notes, and snippets.

@Svastikkka
Last active September 10, 2020 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Svastikkka/dcc0873c47052acc5a214bdab7a11e16 to your computer and use it in GitHub Desktop.
Save Svastikkka/dcc0873c47052acc5a214bdab7a11e16 to your computer and use it in GitHub Desktop.
class Node:
def __init__(self,data):
self.data=data
self.next=None
class LinkedList:
def __init__(self):
self.head=None
self.tail=None
def inputLL(self,arr):
if len(arr)==0:
return
for i in arr:
NewNode=Node(i)
if self.head is None:
self.head=NewNode
self.tail=NewNode
else:
self.tail.next=NewNode
self.tail=NewNode
return self.head
def printLL(self):
if self.head is None:
return
while self.head is not None:
print(self.head.data,end=" ")
self.head=self.head.next
l=LinkedList()
arr=list(map(int,input().split()))
l.inputLL(arr)
l.printLL()
@Svastikkka
Copy link
Author

LinkedList

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment