
linkedlist
jerseyma
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[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.//#61 Rotate List //12ms 90.07% #include <原创 2015-09-02 07:06:28 · 257 阅读 · 0 评论 -
[Leetcode]#237 Delete Node in a Linked List
//#237 Delete Node in a Linked List //20ms 8.09% /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} *原创 2015-09-02 08:12:38 · 230 阅读 · 0 评论 -
[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 ↘原创 2015-09-02 07:47:57 · 255 阅读 · 0 评论 -
[Leetcode]#148 Sort List
//#148 Sort List //60ms 96.38% #include <iostream> using namespace std; class Solution { public: ListNode* sortList(ListNode* head) //decided to use "marge sort", recurrence as the way to sol原创 2015-09-02 07:46:37 · 258 阅读 · 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 the原创 2015-09-02 07:20:55 · 332 阅读 · 0 评论 -
[Leetcode]#19 Remove Nth Node From End of List
//#19 Remove Nth Node From End of List //4ms 100% #include <iostream> using namespace std; /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * L原创 2015-09-02 06:37:23 · 256 阅读 · 0 评论 -
[Leetcode]#234 Palindrome Linked List
//#234 Palindrome Linked List //32ms 14.13% /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *原创 2015-09-02 08:11:16 · 206 阅读 · 0 评论 -
[Leetcode]#141 Linked List Cycle
https://leetcode.com/problems/linked-list-cycle///#141 Linked List Cycle //12ms 100% /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNod原创 2015-09-02 07:39:39 · 285 阅读 · 0 评论 -
[Leetcode]#24 Swap Nodes in Pairs
//#24 Swap Nodes in Pairs //4ms 99.72% #include <iostream> using namespace std;/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int原创 2015-09-02 06:44:40 · 206 阅读 · 0 评论 -
[Leetcode]#2 Add Two Numbers
//#2 Add Two Numbers #include <iostream> using namespace std;/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(原创 2015-09-02 06:25:12 · 239 阅读 · 0 评论 -
[Leetcode]#82 Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example, Given 1->2->3->3->4->4->5, return 1->2->5. Given 1->1->1->2原创 2015-09-02 07:17:37 · 335 阅读 · 0 评论 -
[Leetcode]#206 Reverse Linked List
//#206 Reverse Linked List //8ms 100% #include <iostream> using namespace std;class Solution { public: ListNode* reverseList(ListNode* head) { ListNode *previous_p, *current_p, *next_原创 2015-09-02 07:59:45 · 300 阅读 · 0 评论 -
[Leetcode]#143 Reorder List
https://leetcode.com/problems/reorder-list///#143 Reorder List //64ms 97.92% /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x)原创 2015-09-02 07:43:15 · 366 阅读 · 0 评论 -
[Leetcode]#92 Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note: Given m, n satisfy the following co原创 2015-09-02 07:28:59 · 420 阅读 · 0 评论 -
[Leetcode]#21 Marge Two Sorted Lists
//#21 Marge Two Sorted Lists //12ms 72.02% #include <iostream> using namespace std;/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(原创 2015-09-02 06:40:32 · 236 阅读 · 0 评论 -
[Leetcode]#6 ZigZag Conversion
//#6 ZigZag Conversion //108ms 4.86% class Solution { public: string convert(string s, int numRows) { vector < vector<char> > v_v; while(!s.empty()) { vecto原创 2015-09-02 06:27:08 · 226 阅读 · 0 评论 -
[Leetcode]#147 Insertion Sort List
//#147 Insertion Sort List //80ms 81.07% #include <iostream> using namespace std; /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(i原创 2015-09-02 07:45:14 · 269 阅读 · 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. //#83 Remove Duplicates from So原创 2015-09-02 07:19:02 · 292 阅读 · 0 评论 -
[Leetcode]#203 Remove Linked List Elements
//#203 Remove Linked List Elements //36ms 67.75% /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} *原创 2015-09-02 07:58:42 · 253 阅读 · 0 评论