发布时间:2015-02-04 09:43:04
题目:Write a function to find the longest common prefix string amongst an array of strings.分析:典型题目。LCP问题,即找出字符串数组中最大公共前缀。思路为先找出前两个字符串的公共前缀,再找出该公共前缀与下一个字符串的公共前缀,以此类推,直到找出所有字符串的公共前缀。程序如下:点击(此处)折.........【阅读全文】
发布时间:2015-01-22 17:33:11
题目:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis fo.........【阅读全文】
发布时间:2015-01-21 10:20:21
题目:Determine whether an integer is a palindrome. Do this without extra space.题目给出的hint: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. Howe.........【阅读全文】
发布时间:2015-01-19 21:22:51
题目:Implement atoi to 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 .........【阅读全文】