Skip to content

Instantly share code, notes, and snippets.

@Svastikkka
Created August 6, 2020 05:17
Show Gist options
  • Save Svastikkka/805b1a4b9e0ca5cad67d853dd03bed73 to your computer and use it in GitHub Desktop.
Save Svastikkka/805b1a4b9e0ca5cad67d853dd03bed73 to your computer and use it in GitHub Desktop.
class Node:
def __init__(self,data):
self.data=data
self.next=None
def LinkedList(arr):
head=None
tail=None
if len(arr)<1:
return
else:
for i in arr:
if i ==-1:
break
NewNode = Node(i)
if head == None:
head=NewNode
tail=NewNode
else:
tail.next=NewNode
tail=NewNode
return head
def printLL(head):
arr=[]
while head is not None:
arr.append(head.data)
head=head.next
if arr[0:]==arr[::-1]:
print('true')
else:
print('false')
t=int(input())
for i in range(t):
arr=list(map(int,input().split()))
printLL(LinkedList(arr))
@Svastikkka
Copy link
Author

Palindrome LinkedList

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