编写一个函数,接收一个字符串数组作为输入,找出这些字符串的最大公共前缀。如果没有公共前缀,则返回空字符串。
输入输出要求:
示例:
复制1const input = ["flower", "flow", "flight"]; 2const result = longestCommonPrefix(input); 3console.log(result); // 输出:'fl'
1const input = ["flower", "flow", "flight"]; 2const result = longestCommonPrefix(input); 3console.log(result); // 输出:'fl'
您的会员状态:未登录
题库维护不易,您的支持就是我们最大的动力!