题意:给你两个字符串,让你删除最左端的字母,最终使得两个字符串相等(两个空字符串也是相等的)
思路:逆向思维
ACDAIMA:
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s, t;
while(cin >> s >> t)
{
int len1 = s.length();
int len2 = t.length();
int cnt = 0;
for(int i = len1-1, j = len2-1; i >= 0,j >= 0; i--, j--)
{
if(s[i] == t[j]) cnt += 2;
else break;
}
cout << len1+len2-cnt << endl;
}
}