1 solutions
-
1
#include<bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T--) { string a, b; cin >> a >> b; int lenA = a.size(); int lenB = b.size(); if (abs(lenA - lenB) > 1) { cout << "not similar" << endl; continue; } int i = 0, j = 0; int diff = 0; while (i < lenA && j < lenB) { if (a[i] == b[j]) { i++; j++; } else { diff++; if (diff > 1) break; if (lenA == lenB) { i++; j++; } else if (lenA > lenB) { i++; } else { j++; } } } if (diff <= 1) { cout << "similar" << endl; } else { cout << "not similar" << endl; } } return 0; }
- 1
Information
- ID
- 88
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 7
- Tags
- # Submissions
- 37
- Accepted
- 9
- Uploaded By