首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏代码随想录

    你需要重排链表

    代码如下: class Solution { public: void reorderList(ListNode* head) { vector<ListNode*> vec; 这种方法比操作数组容易一些,不用双指针模拟一前一后了 class Solution { public: void reorderList(ListNode* head) { deque pre = cur; cur = temp; } return pre; } public: void reorderList = nullptr) { cur->next = cur1; } } }; 其他语言版本 Java // 方法三 public class ReorderList { public void reorderList(ListNode head) { ListNode fast = head, slow = head; //

    56310发布于 2021-11-05
  • 来自专栏木又AI帮

    【leetcode刷题】T108-重排链表

    init__(self, x): #         self.val = x #         self.next = None class Solution(object):     def reorderList ListNode *next;  *     ListNode(int x) : val(x), next(NULL) {}  * };  */ class Solution { public:     void reorderList

    45330发布于 2019-07-17
  • 来自专栏前端小书童

    【一天一大 lee】重排链表 (难度:中等) - Day20201020

    . */ var reorderList = function(head) { if (head == null) return // 翻转链表 function reverseList( = beforeList afterList = after } return head } 存储链表节点 使用数组存储节点 声明两个指针分别从数组首尾开始构建 next var reorderList

    51330发布于 2020-11-03
  • 来自专栏用户画像

    Leetcode No.143 重排链表

    三、代码 import utils.ListNode; import java.util.Stack; public class Solution { public void reorderList node2; node2.next=node3; node3.next=node4; node4.next=null; solution.reorderList

    25640发布于 2021-11-29
  • 来自专栏Swift社区

    Swift 实现链表重新排列:L0 → Ln → L1 → Ln-1

    init(_ val: Int) { self.val = val self.next = nil }}func reorderList(_ head: ListNode next } print()}// 示例 1let head1 = createLinkedList([1, 2, 3, 4])reorderList(head1)printLinkedList (head1) // 输出: 1 4 2 3// 示例 2let head2 = createLinkedList([1, 2, 3, 4, 5])reorderList(head2)printLinkedList

    31100编辑于 2024-12-03
  • 来自专栏学习

    链表系列一>重排链表

    val, ListNode next) { this.val = val; this.next = next; } * } */ class Solution { public void reorderList

    17800编辑于 2025-04-28
  • 来自专栏后端知识体系

    LeetCode-143-重排链表

    val, ListNode next) { this.val = val; this.next = next; } * } */ class Solution { public void reorderList val, ListNode next) { this.val = val; this.next = next; } * } */ class Solution { public void reorderList

    46520编辑于 2022-07-14
  • 来自专栏悟道

    143. 重排链表

    class Solution { public void reorderList(ListNode head) { /** 使用双端队列 node.next

    39420发布于 2021-06-21
  • 来自专栏SnailTyan

    Leetcode 143. Reorder List

    ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: void reorderList

    36510发布于 2019-05-25
  • 算法奇妙屋(五)-链表

    代码 (1) 方法一:从中间点prev处开始逆序 public void reorderList(ListNode head) { if (head == null || head.next cur = cur.next; cur2 = cur2.next; } } (2) 方法二:从中间点next处开始逆序 public void reorderList

    13210编辑于 2025-12-19
  • 来自专栏Reck Zhang

    LeetCode 0143 - Reorder List

    ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: void reorderList

    25210发布于 2021-08-11
  • 来自专栏张伦聪的技术博客

    143. 重排链表

    * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public void reorderList

    61910编辑于 2022-10-26
  • 来自专栏计算机视觉与深度学习基础

    Leetcode 143 Reorder List

    ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: void reorderList

    52150发布于 2018-01-12
  • 来自专栏P_M_P学习笔记

    【Leetcode】重排链表、旋转链表、反转链表||

    ListNode { * int val; * struct ListNode *next; * }; */ typedef struct ListNode ListNode; void reorderList /注意先后顺序 cur->next=phead; phead=cur; cur=tmp; } return phead; } void reorderList

    33310编辑于 2024-01-19
  • 来自专栏蛮三刀的后端开发专栏

    [Leetcode][python]Reorder List/重排链表

    翻转后一段 拼接 代码 class Solution: def reorderList(self, head): """ :type head: ListNode

    77730发布于 2019-03-26
  • 来自专栏程序IT圈

    ​LeetCode刷题实战143: 重排链表

    ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: void reorderList

    51350发布于 2021-01-19
  • 来自专栏X

    Leetcode|找单链表中点+链表反转+链表合并|143. 重排链表

    这道题是道综合题,把三个知识点串起来,非常适合复习链表处理的三个技巧 【思路】:观察发现可以把链表后一半进行反转,然后当成两个链表的合并任务即可 class Solution { public: void reorderList

    58030编辑于 2022-01-10
  • 来自专栏Unity3D

    ☆打卡算法☆LeetCode 143. 重排链表 算法解析

    2、代码实现 代码参考: class Solution { public void reorderList(ListNode head) { if (head == null)

    25920编辑于 2022-08-07
  • 来自专栏desperate633

    LintCode 重排链表题目分析代码

    fast.next.next; slow = slow.next; } return slow; } public void reorderList

    38520发布于 2018-08-22
  • 来自专栏皮皮星球

    LinkedList - 143. Reorder List

    * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public void reorderList

    44620发布于 2020-09-23
领券