摘要: http://oj.leetcode.com/problems/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 matter what you leave beyond the new length.思路:和Remove Duplicates from Sorted Array类似,当已经删除n个元素后,需要保留的 阅读全文
posted @ 2013-10-30 14:14 移山测试工作室黑灯老师 阅读(540) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/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 another array, you must do this in place with constant memory.For example,Given i 阅读全文
posted @ 2013-10-30 14:03 移山测试工作室黑灯老师 阅读(435) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/reverse-nodes-in-k-group/Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.You may not alter the values in the nodes, onl 阅读全文
posted @ 2013-10-30 13:39 移山测试工作室黑灯老师 阅读(420) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/swap-nodes-in-pairs/Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You may not modify the values in the list 阅读全文
posted @ 2013-10-28 22:34 移山测试工作室黑灯老师 阅读(880) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/merge-k-sorted-lists/Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路:不停的做两两合并就可以了。 1 class Solution { 2 public: 3 ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { 4 ListNode *head = NULL, *tail = NU... 阅读全文
posted @ 2013-10-28 21:40 移山测试工作室黑灯老师 阅读(890) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/generate-parentheses/Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()()"思路 阅读全文
posted @ 2013-10-28 18:17 移山测试工作室黑灯老师 阅读(1045) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/valid-parentheses/Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" 阅读全文
posted @ 2013-10-28 17:44 移山测试工作室黑灯老师 阅读(361) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/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 removing the second node from the end, the linked list becomes 1->2->3- 阅读全文
posted @ 2013-10-28 17:24 移山测试工作室黑灯老师 阅读(236) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit string "23"Output: ["ad&quo 阅读全文
posted @ 2013-10-28 16:45 移山测试工作室黑灯老师 阅读(527) 评论(0) 推荐(0) 编辑
摘要: http://oj.leetcode.com/problems/4sum/Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:Elements in a quadruplet (a,b,c,d) must be in non-descending order. (ie, a ≤ b ≤ c 阅读全文
posted @ 2013-10-28 16:23 移山测试工作室黑灯老师 阅读(452) 评论(0) 推荐(0) 编辑
count website visits
Buy Computers