Write a function to find the longest common prefix string amongst an array of strings.
Subscribe to see which companies asked this question
比较每个字符串的每个字符,直到第i个不同的字符,或者某个字符串结束
class Solution { public: string longestCommonPrefix(vector<string>& strs) { int v_size = strs.size(); string res = ""; if (0 == v_size) { return res; } if (1 == v_size) { return strs[0]; } int end = 1000; int i; int j; for (i=0; i<end; i++) { char tmp = strs[0][i]; if ('