![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
链表
路漫远吾求索
电子,无线局域网
展开
-
Leetcode——160. Intersection of Two Linked Lists
问题Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘原创 2017-01-15 15:34:11 · 234 阅读 · 0 评论 -
Leetcode——83. Remove Duplicates from Sorted List
问题Given a sorted linked list, delete all duplicates such that each element appear only once.For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3.解答链表的运用! Easy!/** * Definiti原创 2017-01-15 15:54:46 · 308 阅读 · 0 评论 -
Leetcode——203. Remove Linked List Elements
题目Remove all elements from a linked list of integers that have value val.Example Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6 Return: 1 –> 2 –> 3 –> 4 –> 5解答典型的在链表头部多申请一个指针指向链表头部,解决问题!/** * Defin原创 2017-01-15 16:04:46 · 251 阅读 · 0 评论 -
Leetcode——206. Reverse Linked List
题目Reverse a singly linked list.解答反转链表!循环class Solution1 { public: ListNode* reverseList(ListNode* head) { if(head==NULL) return NULL; ListNode *p=head; ListNode *pn=p->next,原创 2017-01-15 16:53:25 · 230 阅读 · 0 评论 -
Leetcode——234. Palindrome Linked List
题目Given a singly linked list, determine if it is a palindrome.Follow up: Could you do it in O(n) time and O(1) space?解答找到链表的一半,把剩下的进行反转,然后比对前后一半。 找到链表的一半:fast和slow两个指针,fast每次递增2,slow每次递增1,也可以用count。原创 2017-01-16 14:10:36 · 229 阅读 · 0 评论 -
Leetcode——142. Linked List Cycle II
题目Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up: Can you solve it without using extra space?原题: https://原创 2017-01-26 00:13:41 · 304 阅读 · 0 评论 -
Leetcode——61. Rotate List
题目Given a list, rotate the list to the right by k places, where k is non-negative.For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL.解答One Solution:/** * Definition for sin原创 2017-01-26 00:55:41 · 319 阅读 · 0 评论 -
Leetcode——86. Partition List
题目Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of th原创 2017-01-26 19:25:20 · 267 阅读 · 0 评论 -
快排-单链表实现
/************************************************************************* > File Name: main.cpp > Author: > Mail: > Created Time: 三 7/26 18:43:04 2017 *****************************原创 2017-07-26 20:28:57 · 705 阅读 · 0 评论