上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 29 下一页

148. Sort List

摘要: Sort a linked list in O(n log n) time using constant space complexity. 用mergeSort.快排的时间复杂度最差是n^2; 阅读全文
posted @ 2017-03-04 08:35 123_123 阅读(55) 评论(0) 推荐(0) 编辑

21. Merge Two Sorted Lists

摘要: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 阅读全文
posted @ 2017-03-04 07:16 123_123 阅读(81) 评论(0) 推荐(0) 编辑

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-> 阅读全文
posted @ 2017-03-04 07:02 123_123 阅读(63) 评论(0) 推荐(0) 编辑

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 阅读全文
posted @ 2017-03-04 02:10 123_123 阅读(65) 评论(0) 推荐(0) 编辑

234. Palindrome Linked List

摘要: Follow up: Could you do it in O(n) time and O(1) space?/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL... 阅读全文
posted @ 2017-03-04 02:02 123_123 阅读(80) 评论(0) 推荐(0) 编辑

206. Reverse Linked List

摘要: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* r... 阅读全文
posted @ 2017-03-04 01:05 123_123 阅读(65) 评论(0) 推荐(0) 编辑

328. Odd Even Linked List

摘要: Example: Given 1->2->3->4->5->NULL, return 1->3->5->2->4->NULL. //The program should run in O(1) space complexity and O(nodes) time complexity. //Plea 阅读全文
posted @ 2017-03-04 00:51 123_123 阅读(81) 评论(0) 推荐(0) 编辑

445. Add Two Numbers II

摘要: Example: 阅读全文
posted @ 2017-03-04 00:08 123_123 阅读(84) 评论(0) 推荐(0) 编辑

237. Delete Node in a Linked List

摘要: Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 3 - 阅读全文
posted @ 2017-03-03 08:26 123_123 阅读(74) 评论(0) 推荐(0) 编辑

替换字符串

摘要: 给定一个字符串,请你将字符串重新编码,将连续的字符替换成“连续出现的个数+字符”。比如字符串AAAABCCDAA会被编码成4A1B2C1D2A。 输入描述: 每个测试输入包含1个测试用例 每个测试用例输入只有一行字符串,字符串只包括大写英文字母,长度不超过10000。 阅读全文
posted @ 2017-03-03 07:54 123_123 阅读(174) 评论(0) 推荐(0) 编辑
上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 29 下一页