最大公共前缀
题目
Write a function to find the longest common prefix string amongst an array of strings.
If there is no common prefix, return an empty string “”.
解析重点
1.大概思路,先找出字符串数组,第一个和第二个字符串公共前缀,然后拿这个公共前缀和第三个字符串比较找出公共部分,依此类推
java代码
1 |
class { |
最大公共前缀
Write a function to find the longest common prefix string amongst an array of strings.
If there is no common prefix, return an empty string “”.
1.大概思路,先找出字符串数组,第一个和第二个字符串公共前缀,然后拿这个公共前缀和第三个字符串比较找出公共部分,依此类推
1 |
class { |
近期评论