既然你的链表允许修改,然后又知道链表的大小的话,可以先用一个指针遍历前半部分链表,并且将其反向:
1->2->3->4->5 ===> 1<-2<-3->4->5
然后从中间往两边遍历并比较就OK了。
-------------------------------------------
PS:贴代码的良好习惯之“排版+高亮+分块+注释=有人看”
1->2->3->4->5 ===> 1<-2<-3->4->5
然后从中间往两边遍历并比较就OK了。
-------------------------------------------
PS:贴代码的良好习惯之“排版+高亮+分块+注释=有人看”
If you're not failing every now and again, it's a sign you're not doing anything very innovative.