摘要: 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 fo 阅读全文
posted @ 2017-02-15 13:54 notesbuddy 阅读(138) 评论(0) 推荐(0)
摘要: 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 a 阅读全文
posted @ 2017-02-15 11:41 notesbuddy 阅读(108) 评论(0) 推荐(0)
摘要: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 两种方法: (1) 类似于归并排序,把链表数组分割成两两最小的链表对(可能存在落单的情况,要做处理), 阅读全文
posted @ 2017-02-15 11:21 notesbuddy 阅读(142) 评论(0) 推荐(0)
摘要: 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 @ 2017-02-15 10:45 notesbuddy 阅读(198) 评论(0) 推荐(0)
摘要: 转自 一亩三分地的 回复: http://www.1point3acres.com/bbs/thread-172641-1-1.html 所谓Backtracking都是这样的思路:在当前局面下,你有若干种选择。那么尝试每一种选择。如果已经发现某种选择肯定不行(因为违反了某些限定条件),就返回;如果 阅读全文
posted @ 2017-02-15 00:52 notesbuddy 阅读(211) 评论(0) 推荐(0)
摘要: Given a linked list, remove the nth node from the end of list and return its head. For example, Note:Given n will always be valid.Try to do this in on 阅读全文
posted @ 2017-02-14 23:51 notesbuddy 阅读(168) 评论(0) 推荐(0)
摘要: 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 whic 阅读全文
posted @ 2017-02-14 23:14 notesbuddy 阅读(735) 评论(0) 推荐(0)
摘要: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. 阅读全文
posted @ 2017-02-14 22:21 notesbuddy 阅读(178) 评论(0) 推荐(0)
摘要: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of 阅读全文
posted @ 2017-02-14 19:53 notesbuddy 阅读(137) 评论(0) 推荐(0)
摘要: 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. tag : du 阅读全文
posted @ 2017-02-14 19:01 notesbuddy 阅读(163) 评论(0) 推荐(0)