This commit is contained in:
Gyubin Han
2025-02-19 14:09:55 +09:00
parent e3c6c8b32a
commit dede0dca01
36 changed files with 555 additions and 0 deletions

16
leetcode/234.py Normal file
View File

@@ -0,0 +1,16 @@
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def isPalindrome(self, head: Optional[ListNode]) -> bool:
l=[]
while not head==None:
l.append(head.val)
head=head.next
for i in range(len(l)//2):
if not l[i]==l[-i-1]:
return False
return True