Longest common prefix
此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
最长公共前缀
返回能作为数组中每个单词开头的最长字符串。对于 flower、flow、flight,答案是 fl;如果没有公共部分,返回 ""。先用第一个单词作为猜测,然后对照后面每个单词不断缩短,直到它适配所有单词。
难度 5/5 · 今日首次完成可获 400 金币及少量额外奖励
Complete longestCommonPrefix(String[] strs) returning the longest prefix shared by every string. Return an empty string if there is none or the array is empty.
点击“运行”查看此处输出。