
链表
weixin_42741175
这个作者很懒,什么都没留下…
展开
-
leetcode 19. 删除链表的倒数第N个节点
给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。示例:给定一个链表: 1->2->3->4->5, 和 n = 2.当删除了倒数第二个节点后,链表变为 1->2->3->5.说明:给定的 n 保证是有效的。进阶:你能尝试使用一趟扫描实现吗?使用快慢指针方法一://快慢指针/** * Definition for ...原创 2020-04-27 16:52:11 · 131 阅读 · 1 评论 -
leetcode 203.Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.Example:Input: 1->2->6->3->4->5->6, val = 6Output: 1->2->3->4->5大意:移除等于val的元素(可能不止一个)方法:遍历链表,...原创 2019-05-07 23:38:22 · 224 阅读 · 0 评论 -
leetcode112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note: A leaf is a node with no children.Example:G...原创 2019-05-06 22:49:08 · 172 阅读 · 0 评论 -
leetcode 61. Rotate List
Given a linked list, rotate the list to the right by k places, where k is non-negative.Example 1:Input: 1->2->3->4->5->NULL, k = 2Output: 4->5->1->2->3->NULLExplanati...原创 2019-05-06 20:36:39 · 110 阅读 · 0 评论 -
leetcode92. Reverse Linked List II
Reverse a linked list from position m to n. Do it in one-pass.Note: 1 ≤ m ≤ n ≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4Output: 1->4->3->2->5->...原创 2019-05-06 20:19:48 · 90 阅读 · 0 评论 -
leetcode206. Reverse Linked List
Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can be reversed either iteratively or recursively. ...原创 2019-05-06 19:39:10 · 89 阅读 · 0 评论