Linklist中快慢指针找链表中点

这是一个非常精巧的设计。

发现问题:在做leetcode时发现一个题目, 就是判断链表是否为回文链表,如何判断呢?

解决问题:一个思路就是找到链表中点,然后反转后边链表。与前半链表对比看是否一致

引出问题:如何找到链表中点?

This is the topic of the article,what i want to say is that,using a cool idea to solve the problem,the steps  code would be  shown:

 

Linklist Find_mid_list(Linklist *q)
{

Linklist slow,fast;
while(fast&&fast->next)
{
   slow=slow->next;

   fast = fast->next->next;

}
  return slow;


}

  

 

posted @ 2020-09-22 17:03  WhyNot686  阅读(143)  评论(0)    收藏  举报