上一页 1 ··· 38 39 40 41 42 43 44 45 46 ··· 51 下一页
2013年12月31日
摘要: Reverse Linked List II2013.12.31 16:00Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.Note:Givenm,nsatisfy the following condition:1 ≤m≤n≤ length of list.Solution1: Rever 阅读全文
posted @ 2013-12-31 16:37 zhuli19901106 阅读(207) 评论(0) 推荐(0)
2013年12月27日
摘要: Subsets II2013.12.27 02:47Given a collection of integers that might contain duplicates,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,2], a solution is:[ [2], [1], [1,2,2], [2,2], ... 阅读全文
posted @ 2013-12-27 02:50 zhuli19901106 阅读(432) 评论(0) 推荐(0)
摘要: Decode Ways2013.12.27 02:32A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total number of ways to decode it.For example,Given encoded me 阅读全文
posted @ 2013-12-27 02:47 zhuli19901106 阅读(246) 评论(0) 推荐(0)
摘要: Gray Code2013.12.27The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0.For example, givenn= 2, return[0,1,3, 阅读全文
posted @ 2013-12-27 02:28 zhuli19901106 阅读(334) 评论(0) 推荐(0)
摘要: Merge Sorted Array2013.12.27 01:18Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hold additional elements from B. The number of elements initialized in A and B aremandnrespectively.Solution1: First solution is simple and fo. 阅读全文
posted @ 2013-12-27 02:08 zhuli19901106 阅读(229) 评论(0) 推荐(0)
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 阅读(205) 评论(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 阅读(152) 评论(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 阅读(186) 评论(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 阅读(205) 评论(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 阅读(175) 评论(0) 推荐(0)
上一页 1 ··· 38 39 40 41 42 43 44 45 46 ··· 51 下一页