不在状态,坐的我屁股疼
class Solution {
public:
/**
*
* @param strs string字符串vector
* @return string字符串
*/
string longestCommonPrefix(vector<string>& strs) {
if (strs.empty()) {
return std::string();
}
for (int i = 0; i < strs[0].size(); ++i) {
char tmp = strs[0][i];
for (int j = 1; j < strs.size(); ++j) {
if (tmp != strs[j][i] || i >= strs[j].size()) {
return strs[0].substr(0, i);
}
}
}
return strs[0];
}
};