Skip to content

Commit 36ec56f

Browse files
committed
Time: 31 ms (61.89%), Space: 39.4 MB (27.58%) - LeetHub
1 parent 5f163ac commit 36ec56f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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: Optional[ListNode]) -> bool:
8+
numList = []
9+
while head:
10+
numList.append(head.val)
11+
head = head.next
12+
13+
return numList == numList[::-1]

0 commit comments

Comments
 (0)