2013年12月26日
摘要: Partition List2013.12.26 22:58Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in each of the two partitions.For example,Given1->4->3->2->5->2andx= 3,re 阅读全文
posted @ 2013-12-26 23:00 zhuli19901106 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Remove Duplicates from Sorted List II2013.12.26 21:42Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3->3->4->4->5, return1->2->5.Given1->1->1->2->3, return2->3. 阅读全文
posted @ 2013-12-26 22:00 zhuli19901106 阅读(144) 评论(0) 推荐(0) 编辑
摘要: Remove Duplicates from Sorted List2013.12.26 21:36Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, return1->2->3.Solution: Removing the duplicates from a list requires two poin 阅读全文
posted @ 2013-12-26 21:42 zhuli19901106 阅读(177) 评论(0) 推荐(0) 编辑
摘要: Search in Rotated Sorted Array II2013.12.26 20:07Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in the array.Solution1: First comes the link to the old ori 阅读全文
posted @ 2013-12-26 20:13 zhuli19901106 阅读(187) 评论(0) 推荐(0) 编辑
摘要: Remove Duplicates from Sorted Array II2013.12.26 15:28Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should return length =5, and A is now[1,1,2,2,3].Solution: We've done the problem "Remo 阅读全文
posted @ 2013-12-26 15:30 zhuli19901106 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Subsets2013.12.26 15:19Given a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,IfS=[1,2,3], a solution is:[ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], []]Soluti... 阅读全文
posted @ 2013-12-26 15:22 zhuli19901106 阅读(891) 评论(0) 推荐(0) 编辑