[LeetCode] Remove Nth Node From End of List 解题报告

摘要: Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After ... 阅读全文
posted @ 2012-12-31 14:01 小刀初试 阅读(140) 评论(0) 推荐(0)

[LeetCode] Remove Element 解题报告

摘要: Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat... 阅读全文
posted @ 2012-12-31 12:54 小刀初试 阅读(85) 评论(0) 推荐(0)

[LeetCode] 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, ... 阅读全文
posted @ 2012-12-31 12:19 小刀初试 阅读(135) 评论(0) 推荐(0)

[LeetCode] Remove Duplicates from Sorted Array II 解题报告

摘要: Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function should r... 阅读全文
posted @ 2012-12-31 12:00 小刀初试 阅读(134) 评论(0) 推荐(0)

[LeetCode] Remove Duplicates from Sorted Array 解题报告

摘要: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for... 阅读全文
posted @ 2012-12-31 11:44 小刀初试 阅读(155) 评论(0) 推荐(0)

[LeetCode] Pow(x, n) 解题报告

摘要: Implement pow(x, n).» Solve this problem[解题思路]二分法,注意n<0的情况。[Code]1: double power(double x, int n) 2: { 3: if (n == 0) 4: return... 阅读全文
posted @ 2012-12-31 11:19 小刀初试 阅读(109) 评论(0) 推荐(0)

[LeetCode] Recover Binary Search Tree 解题报告

摘要: Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ... 阅读全文
posted @ 2012-12-31 09:46 小刀初试 阅读(107) 评论(0) 推荐(0)

[LeetCode] Populating Next Right Pointers in Each Node II 解题报告

摘要: Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil... 阅读全文
posted @ 2012-12-30 12:33 小刀初试 阅读(128) 评论(0) 推荐(0)

[LeetCode] Populating Next Right Pointers in Each Node 解题报告

摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文
posted @ 2012-12-30 09:27 小刀初试 阅读(166) 评论(0) 推荐(0)

[LeetCode] Plus One 解题报告

摘要: Given a number represented as an array of digits, plus one to the number.» Solve this problem[解题思路]加位与进位。模拟。[Code]1: vector plusOne(vector &digits) {... 阅读全文
posted @ 2012-12-30 08:23 小刀初试 阅读(129) 评论(0) 推荐(0)