Guest User

Untitled

a guest
Oct 27th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. QWERTY12345 YU
  2. QWER TY4564 F
  3. QWERGH145
  4. QWER T777
  5. QWE RBT
  6.  
  7. public static string CommonString(string first, string second)
  8. {
  9. return new string((first.Intersect(second)).ToArray());
  10. }
  11.  
  12. string common(const vector<string>& sts)
  13. {
  14. for(int i = 0;;++i)
  15. {
  16. bool ok = true;
  17. for(int j = 1; j < sts.size(); ++j)
  18. {
  19. if (sts[j-1][i] != sts[j][i])
  20. {
  21. ok = false;
  22. break;
  23. }
  24. }
  25. if (ok == false) return sts[0].substr(0,i);
  26. }
  27. }
Add Comment
Please, Sign In to add comment