题意: Write a function to find the longest common prefix string amongst an array of strings. (Easy) 这两天实验室项目太忙了, 老板各种活,只能挑着先水几道easy题,这两个题是昨天做的没来得及写总结. 分析: 暴力的想法遍历比较一下就行,注意遍历的始末位置.优化的话改天再看看discuss 代码: class Solution { public: string longestCommonPrefix(…
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 "". Example 1: Input: ["flower","flow","flight"] Output: "fl" Exa…
public class Solution { public string LongestCommonPrefix(string[] strs) { ) { return ""; } ) { ]; } else { ; var len = strs.Length; while (true) { ; i < len - ; i++) { var s1 = strs[i]; ]; if (s1.Length < maxLen || s2.Length < maxLen)…