Leetcode刷题——单链表2

Leetcode刷题——单链表2

练习题1 链表分割 思路:将链表一分为2,以x为界限,大于x的尾插到新链表1,小于x的尾插到新链表2,之后再将新链表1,头插到新链表2,跟归并排序有点像class Partition { public: ListNode* partition(ListNode* pHead, int x) ...

[LeetCode] Linked List Cycle 单链表中的环

Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 这道题是快慢指针的经典应用。只需要设两个指针,一个每次走一步的慢指针和一个每次...

[LeetCode] Linked List Cycle II 单链表中的环之二

Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you solve it without using extra s...

本页面内关键词为智能算法引擎基于机器学习所生成,如有任何问题,可在页面下方点击"联系我们"与我们沟通。