![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
链表
链表
Haha@25
300字以内
展开
-
328. Odd Even Linked List
我的解答:/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ /** 内容:LeetCode.328 奇偶结点分开 时间:2020/1...原创 2020-01-18 13:34:26 · 117 阅读 · 0 评论 -
725. Split Linked List in Parts
本题的关键是如何分割;若已知单链表长度为n,要分成k部分则,每部分至少有 n/k个结点;前n%k个结点有n/k+1个节点/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val...原创 2020-01-18 11:49:38 · 109 阅读 · 0 评论 -
234. Palindrome Linked List
我的解法:新建一个逆置的单链表;如果逆置的单链表和原单链表元素内容相同,则是回文;/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */clas...原创 2020-01-17 22:45:35 · 78 阅读 · 0 评论 -
445. Add Two Numbers II
对两个链表逆置;从低位开始逐位进行加法运算;对最高位的进位要生成新的结点;/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } *//** ...原创 2020-01-17 21:27:55 · 134 阅读 · 0 评论 -
24. Swap Nodes in Pairs
迭代法/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */class Solution { public ListNode swapPa...原创 2020-01-17 17:33:36 · 68 阅读 · 0 评论 -
19. Remove Nth Node From End of List
方法一,不设置头节点,要进行特殊情况的处理特殊情况为:删除的为第一个节点,或者只有单链表第一个节点,或者为空链表;/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x;...原创 2020-01-17 16:40:11 · 82 阅读 · 0 评论 -
83. Remove Duplicates from Sorted List
迭代法:/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */class Solution { public ListNode delet...原创 2020-01-17 14:34:38 · 80 阅读 · 0 评论 -
21. Merge Two Sorted Lists
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */class Solution { public ListNode mergeTwoLis...原创 2020-01-17 12:42:44 · 108 阅读 · 0 评论 -
206. Reverse Linked List
要反工,怪怪的/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */class Solution { public ListNode re...原创 2020-01-16 16:25:14 · 75 阅读 · 0 评论