![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
链表
str_818
这个作者很懒,什么都没留下…
展开
-
【Leetcode】2. 两数相加(Add Two Numbers)
Leetcode - 2 Add Two Numbers (Medium)题目描述:使用链表表示两个正整数,返回两正整数相加结果,使用链表表示。Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)Output: 7 -> 0 -> 8Explanation: 342 + 465 = 807.public ListNode addT...原创 2019-06-02 11:06:21 · 205 阅读 · 0 评论 -
【Leetcode】19. 删除链表的倒数第 n 个节点(Remove Nth Node From End of List)
Leetcode - 19 Remove Nth Node From End of List (Medium)Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked list becomes 1->2->3->...原创 2019-06-04 09:02:57 · 138 阅读 · 0 评论 -
【Leetcode】21. 合并两个有序链表(Merge Two Sorted Lists)
Leetcode - 21 Merge Two Sorted Lists (Easy)Input: 1->2->4, 1->3->4Output: 1->1->2->3->4->4解法一:迭代public ListNode mergeTwoLists(ListNode l1, ListNode l2) { ListNode d...原创 2019-06-04 22:25:19 · 126 阅读 · 0 评论 -
【Leetcode】23. 合并 k 个有序链表(Merge k Sorted Lists)
Leetcode - 23 Merge k Sorted Lists (Hard)Input:[ 1->4->5, 1->3->4, 2->6]Output: 1->1->2->3->4->4->5->6解题思路:这道题类似之前的合并两个有序链表,可以逐个两两合并,也可以每次取出链表头部的最小节点,我也...原创 2019-06-04 22:52:53 · 192 阅读 · 0 评论