上一页 1 ··· 5 6 7 8 9 10 下一页
摘要: Given a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thesamerepeated number may be chosen fromCunlimited number of times.Note:All numbers (including target) will be positive integers.Elements in a combination (a1,a2, � ,ak 阅读全文
posted @ 2013-09-04 11:36 LEDYC 阅读(186) 评论(0) 推荐(0)
摘要: The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"two 1s"or21.21is read off as"one 2, thenone 1"or1211.Given an integern, generate thenthsequence.Note: The sequence of inte 阅读全文
posted @ 2013-09-04 10:56 LEDYC 阅读(149) 评论(0) 推荐(0)
摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Here are few examples.[1,3,5,6], 5 → 2[1,3,5,6], 2 → 1[1,3,5,6], 7 → 4[1,3,5,6], 0 → 0---BST---public cl 阅读全文
posted @ 2013-09-04 09:48 LEDYC 阅读(159) 评论(0) 推荐(0)
摘要: Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order ofO(logn).If the target is not found in the array, return[-1, -1].For example,Given[5, 7, 7, 8, 8, 10]and target value 8,return[3, 4].---public 阅读全文
posted @ 2013-09-04 09:39 LEDYC 阅读(152) 评论(0) 推荐(0)
摘要: Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its index, otherwise return -1.You may assume no duplicate exists in the array.---Basic idea is Binary search-i 阅读全文
posted @ 2013-09-04 09:25 LEDYC 阅读(163) 评论(0) 推荐(0)
摘要: Divide two integers without using multiplication, division and mod operator.---public class Solution { public int divide(int dividend, int divisor) { boolean sign1 = dividend >=0; boolean sign2 = divisor >=0; long a = Math.abs((long)dividend); long b = ... 阅读全文
posted @ 2013-09-02 05:24 LEDYC 阅读(130) 评论(0) 推荐(0)
摘要: mplement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.---public class Solution { public String strStr(String haystack, String needle) { if(haystack == null || needle == null) return null; int... 阅读全文
posted @ 2013-09-02 04:51 LEDYC 阅读(165) 评论(0) 推荐(0)
摘要: 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.---Similar to 25, remove dup from a sorted array---public class Solution { public int removeElement(int[] 阅读全文
posted @ 2013-09-02 04:48 LEDYC 阅读(273) 评论(0) 推荐(0)
摘要: Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.For example,Given input array A =[1,1,2],Your function should return length =2, and A is 阅读全文
posted @ 2013-09-02 04:07 LEDYC 阅读(140) 评论(0) 推荐(0)
摘要: Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-out nodes in the end should remain as it is.You may not alter the values in the nodes, only nodes itself may be changed.Only constant memory is allowed 阅读全文
posted @ 2013-09-02 03:59 LEDYC 阅读(181) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 下一页