摘要:        
我的解法 没有什么需要推理的地方,要注意一开始要让cur走的比odd和even快,否则会导致cur的next被odd和even修改,代码里有注释。 ListNode *oddEvenList(ListNode *head) { if (!head) { return head; } ListNode    阅读全文
posted @ 2024-10-21 16:57
Gold_stein
阅读(12)
评论(0)
推荐(0)
        
            
        
        
摘要:        
Leetcode 141. Linked List Cycle 解法一 直接给遍历过的点打标记,再回来就说明有环。 class Solution { public: const int N = 100005; bool hasCycle(ListNode *head) { ListNode *cur    阅读全文
posted @ 2024-10-21 15:01
Gold_stein
阅读(23)
评论(0)
推荐(0)
        
            
        
        
摘要:        
Leetcode 160. Intersection of Two Linked Lists 错解 一开始没看清题目的要求中,提到最后表结构不能变,想到的做法是: 先遍历A,把A翻转,然后B就可以走到headA判断出它们是否相交,但是即便如此,也不能判断出相交点在哪里,而且还会破坏链表的结构,所以这    阅读全文
posted @ 2024-10-21 14:30
Gold_stein
阅读(25)
评论(0)
推荐(0)
        

 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号