Write a function to find the longest common prefix string amongst an array of strings.
题目大意
写一个函数来找出所有字符串里最长的公共前缀。
难度系数:容易
实现
题目不难,基本思路大家都能想到,就是一些细节可能会遗漏。这个也没啥好算法,不管怎样,都需要一个个去比较。 所以没啥好说...
分类:
其他好文 时间:
2015-01-27 18:24:51
阅读次数:
103
题目:Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining...
分类:
移动开发 时间:
2015-01-27 00:08:51
阅读次数:
185
题目:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the ...
分类:
编程语言 时间:
2015-01-26 20:42:03
阅读次数:
180
题目:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty spac...
分类:
编程语言 时间:
2015-01-26 16:57:37
阅读次数:
161
题目:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any poi...
分类:
编程语言 时间:
2015-01-26 16:32:36
阅读次数:
173
题目:Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?...
分类:
编程语言 时间:
2015-01-24 21:12:54
阅读次数:
192
题目:Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red,...
分类:
编程语言 时间:
2015-01-24 19:58:37
阅读次数:
213
题目: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...
分类:
编程语言 时间:
2015-01-24 12:58:48
阅读次数:
285
题目:A peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and return its ind...
分类:
编程语言 时间:
2015-01-23 00:42:53
阅读次数:
277
题目:Given an array of sizen, find the majority element. The majority element is the element that appears more than? n/2 ?times.You may assume that the ...
分类:
编程语言 时间:
2015-01-22 17:31:28
阅读次数:
159