LeetCode之链表
黄焖鸡米饭啊
嗯。
展开
-
删除排序链表中的重复元素
题目: 给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次。 示例1: 输入: 1->1->2 输出: 1->2 示例2: 输入: 1->1->2->3->3 输出: 1->2->3 思路:使用双指针法,p1指向一个节点,p2指向下一个和p1不重复的节点,将p1的next指向p2,p1和p2之间重复的节点即被删除,重复这...原创 2019-10-13 17:39:36 · 318 阅读 · 0 评论 -
Reverse_Nodes_in_kGroup
题目描述: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the原创 2018-01-05 13:35:02 · 184 阅读 · 0 评论 -
Merge_k_Sorted_Lists
题目描述:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.(合并k个有序链表).思路:普通思路就是把每条链表单拿出来遍历,然后将链表中的元素一个一个往结果集中按大小放,直到所有链表都被遍历完。如果有n条链表,每个list的最大长度是m,假如使用,时间复...原创 2017-12-29 21:10:38 · 186 阅读 · 0 评论 -
Remove Nth Node From End of List
题目描述:Given a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the...原创 2018-07-02 20:00:44 · 106 阅读 · 0 评论 -
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->NULLExplanat...原创 2018-07-03 20:06:56 · 218 阅读 · 0 评论 -
Add Two Numbers
题目描述:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and ret...原创 2018-07-04 17:30:22 · 102 阅读 · 0 评论