fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  5.  
  6. string s1, s2;
  7. cin >> s1 >> s2;
  8. if (s2.length() == s1.length() + 1) {
  9. bool flag = false;
  10. int i = 0, j = 0;
  11.  
  12. while (i < s1.length() && j < s2.length()) {
  13. if (s1[i] != s2[j]) {
  14. if (flag) {
  15. cout << "No\n";
  16. return 0;
  17. }
  18. flag = true;
  19. j++;
  20. } else {
  21. i++;
  22. j++;
  23. }
  24. }
  25. cout << "Yes\n";
  26. } else {
  27. cout << "No\n";
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
No