随笔分类 -  LinkList

Summary For the LinkList
摘要:Keep in mind that there are two ways to deal with the LinkList very easily.1. Using the vector to store every item of the list, then we can use the in... 阅读全文
posted @ 2015-04-14 08:34 又岸 阅读(79) 评论(0) 推荐(0)
Leetcode 25 Reverse Nodes in K-Group
摘要:Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o... 阅读全文
posted @ 2015-04-14 08:29 又岸 阅读(99) 评论(0) 推荐(0)
Leetcode 24 Swap Nodes in Pairs
摘要:/** * ID: 24 * Name: Swap Nodes in Pairs * Data Structure: Linked List * Time Complexity: * Space Complexity: * Tag: LinkList * Difficult: Medium ... 阅读全文
posted @ 2015-04-14 04:56 又岸 阅读(140) 评论(0) 推荐(0)
Leetcode 92 Reverse Linked List ii
摘要:/** * ID: 92 * Name: Reverse Linked List * Data Structure: Linked List * Time Complexity: * Space Complexity: * Tag: LinkList * Difficult: Medium ... 阅读全文
posted @ 2015-04-14 01:50 又岸 阅读(98) 评论(0) 推荐(0)
Leetcode 2 Add Two Numbers
摘要:/** * ID: 2 * Name: Add Two Numbers * Data Structure: Linked List * Time Complexity: * Space Complexity: * Tag: LinkList * Difficult: Medium * Pro... 阅读全文
posted @ 2015-04-13 03:46 又岸 阅读(101) 评论(0) 推荐(0)
Leetcode 86 Partition List
摘要:关于List换位置移动,一个很好的解决途径就是 使用 vector 来储存 ListNode *, 然后可以方便的计算其长度 v.size() 并且进行移动,删改等操作。注意:1. 其实vector操作和真实指针移动操作的时间差不太多。2. 还要记得判断head是否为NULL3. 在使用 v->ne... 阅读全文
posted @ 2015-04-12 09:11 又岸 阅读(144) 评论(0) 推荐(0)
Leetcode 61 Rotate List
摘要:/** * ID: 61 * Name: Rotate List * Data Structure: Linked List * Time Complexity: * Space Complexity: * Tag: LinkList * Difficult: Medium * Probl... 阅读全文
posted @ 2015-04-12 03:10 又岸 阅读(118) 评论(0) 推荐(0)
Leetcode 19 Remove Nth Node From End of List
摘要:本题有三种解法:第一种: 老实的做两次遍历,第一次遍历得到整个链表数组的大小,然后做减法,求出正序的位置。第二种: 用vector来直接存储每个item,然后利用vector.size()计算出正序的位置,直接删除。第三种: 也是最屌的方法。让pre,cur往后走,但忽略n次,也就是只走总次数-n次... 阅读全文
posted @ 2015-04-11 14:35 又岸 阅读(107) 评论(0) 推荐(0)
Leetcode 82 Remove Duplicates from Sorted List 2
摘要:* Problem: * Given a sorted linked list, delete all nodes that have duplicate numbers * leaving only distinct numbers from the original list. * Solut... 阅读全文
posted @ 2015-04-11 11:25 又岸 阅读(106) 评论(0) 推荐(0)