We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b77af99 commit a8bc92bCopy full SHA for a8bc92b
Fast & Slow Pointers/Easy/Palindrome Linked List.py
@@ -0,0 +1,17 @@
1
+# Definition for singly-linked list.
2
+# class ListNode:
3
+# def __init__(self, val=0, next=None):
4
+# self.val = val
5
+# self.next = next
6
+class Solution:
7
+ def isPalindrome(self, head: ListNode) -> bool:
8
+ stack = []
9
+ ptr = head
10
+ while ptr != None:
11
+ stack.append(ptr.val)
12
+ ptr = ptr.next
13
+ while head != None:
14
+ if head.val != stack.pop():
15
+ return False
16
+ head = head.next
17
+ return True
0 commit comments