摘要:
Write a function to find the longest common prefix string amongst an array of strings.方法1:BF, 首先计算两个字符串的prefix,每次用这个prefix与下一个字符串生成新的prefix效果较差,大数据集直接挂了,代码可读性太差-_-! 1 public String longestCommonPrefix(String[] strs) { 2 // Start typing your Java solution below 3 // DO NOT write main(... 阅读全文
摘要:
Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of lineiis at (i,ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.Note: You 阅读全文
摘要:
Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to string, note the restriction of using extra space.You could also try reversing an integer. However, if you have solved 阅读全文
摘要:
Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.Notes:It is intended for this problem to be specified vaguely (ie, no given input specs). You are respo 阅读全文