Skip to content

Instantly share code, notes, and snippets.

@Svastikkka
Created August 10, 2020 15:36
Show Gist options
  • Save Svastikkka/a8b2826011ef73e92b88f71b6e5b2d29 to your computer and use it in GitHub Desktop.
Save Svastikkka/a8b2826011ef73e92b88f71b6e5b2d29 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')
arr=list(map(int,input().split()))
printLL(LinkedList(arr))
@Svastikkka
Copy link
Author

Interview Shuriken 46: Is Palindrome

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