摘要:
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.用 阅读全文
摘要:
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest palindromic substring.用一个指针从0遍历到s.size()-1,从里向外来检测子串是否是回文,分两种情况:1)bab, 2)bb。也就是当前指针可能指向的是奇数回文,也可能是偶数回文。做两次检测。 1 class Solution { 2 public: 3 string ... 阅读全文
摘要:
Write a function to find the longest common prefix string amongst an array of strings.模拟法,先选取第一个字符串,之后依次和后面的字符串得出LCP 1 class Solution { 2 public: 3 string longestCommonPrefix(vector<string> &strs) { 4 // Start typing your C/C++ solution below 5 // DO NOT write int main() function... 阅读全文
摘要:
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", &q 阅读全文
摘要:
Given a stringsconsists 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,Givens="Hello Worl 阅读全文
摘要:
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], returntrue.A =[3,2,1,0,4], returnfalse.用贪 阅读全文