找出最长公共前缀字符串


Submit solution

Points: 10
Time limit: 1.0s
Memory limit: 8M

Author:
Problem type
Allowed languages
C++

题目描述:

第一行输入一个整数,表示字符串数组有多少个元素

第二行,依次输入字符串数组的各个元素,用空格隔开。

找到字符串数组中最长的公共前缀字符串。

如果不存在公共前缀,则返回空字符串 ""。

示例 1:

输入:

3

flower flow flight

输出:

"fl"

示例 2:

输入:

3

dog racecar car

输出:

""

解释: 输入字符串中不存在公共前缀。

约束条件:

1≤strs.length ≤200
0≤strs[i].length≤200
strs[i] 仅包含小写英文字母。

Comments

There are no comments at the moment.