题目摘要
寻找字符串数组中字符串的最长公共前缀
解法
1. 把第一个字符串当做前缀,依次比较后面的字符串,减小前缀长度
2. 依次比较所有字符串的每个字母,增加前缀长度
注意
1. 只需要知道前缀长度,最后剪切字符串就行
原题
Write a function to find the longest common prefix string amongst an array of strings.
题目摘要
寻找字符串数组中字符串的最长公共前缀
解法
1. 把第一个字符串当做前缀,依次比较后面的字符串,减小前缀长度
2. 依次比较所有字符串的每个字母,增加前缀长度
注意
1. 只需要知道前缀长度,最后剪切字符串就行
原题
Write a function to find the longest common prefix string amongst an array of strings.