Created
August 10, 2020 15:36
-
-
Save Svastikkka/a8b2826011ef73e92b88f71b6e5b2d29 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Interview Shuriken 46: Is Palindrome