摘要: Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.Your algorithm should run in O(n) complexity. The key point is that for each nu.. 阅读全文
posted @ 2013-07-24 22:51 冰点猎手 阅读(192) 评论(0) 推荐(0)
摘要: Write a function to find the longest common prefix string amongst an array of strings. class Solution {public: string longestCommonPrefix(vector &strs) { // Start typing your C/C++ solution below // DO NOT write int main() function string result=""; if(strs.size() == ... 阅读全文
posted @ 2013-07-24 22:01 冰点猎手 阅读(159) 评论(0) 推荐(0)
摘要: 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", "ae", "af", "bd", "be", & 阅读全文
posted @ 2013-07-24 21:47 冰点猎手 阅读(211) 评论(0) 推荐(0)
摘要: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defined as a character sequence consists of non-space characters only.For example,Given s = "Hel 阅读全文
posted @ 2013-07-24 20:33 冰点猎手 阅读(194) 评论(0) 推荐(0)
摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to reach the last index in the minimum number of jumps.For example:Given array A = [2,3,1,1,4]The minimum. 阅读全文
posted @ 2013-07-24 11:17 冰点猎手 阅读(233) 评论(0) 推荐(0)
摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you are able to reach the last index.For example:A = [2,3,1,1,4], return true.A = [3,2,1,0,4], return fal. 阅读全文
posted @ 2013-07-24 09:20 冰点猎手 阅读(265) 评论(0) 推荐(0)