/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
bool isPalindrome(struct ListNode* head){
int count=0;
int a[100000];
while(head){
a[count]=head->val;
head=head->next;
count++;
}
int left=0;
int right=count-1;
while(left<right){
if(a[left]!=a[right]){
return false;
}
left++;
right--;
}
return true;
}
力扣------回文链表
最新推荐文章于 2024-05-18 15:56:15 发布