Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- QWERTY12345 YU
- QWER TY4564 F
- QWERGH145
- QWER T777
- QWE RBT
- public static string CommonString(string first, string second)
- {
- return new string((first.Intersect(second)).ToArray());
- }
- string common(const vector<string>& sts)
- {
- for(int i = 0;;++i)
- {
- bool ok = true;
- for(int j = 1; j < sts.size(); ++j)
- {
- if (sts[j-1][i] != sts[j][i])
- {
- ok = false;
- break;
- }
- }
- if (ok == false) return sts[0].substr(0,i);
- }
- }
Add Comment
Please, Sign In to add comment