求最长前缀
#include
#include
#include
using namespace std;
class Solution {
public:
string longestCommonPrefix(vector
& strs) {
int i=0;
int index=0;
int lenth=strs.size();
if(lenth==0)
return "";
int count=strs[0].size();
int isOver=0;
while( index
strs[i].size() || strs[i][index]!=strs[0][index]) { isOver=1; break; } } if(isOver==1) break; index++; } return strs[0].substr(0,index); } }; int main() { Solution s; vector
strs; //strs.push_back("abcjkl"); //strs.push_back("abckk"); //strs.push_back("abch"); //strs.push_back("abc2"); cout<
<