//判断一个链表是否为回文结构
//利用栈结构
public boolean isPalindrome(Node head){
Stack<Node> stack=new Stack<Node>();
Node cur=head;
while(cur!=null){
stack.push(cur);
cur=cur.next;
}
while(head!=null){
if(head.value!=stack.pop().value){
return false;
}
head=head.next;
}
return true;
}
链表-判断一个链表是否为回文结构
猜你喜欢
转载自blog.csdn.net/weixin_42146769/article/details/88381750
今日推荐
周排行