题目链接
class Solution {
public:
bool isLongPressedName(string name
, string typed
) {
int n1
= name
.size();
int n2
= typed
.size();
int i
= 0, j
= 0;
while (j
< n2
) {
if (i
< n1
&& name
[i
] == typed
[j
]) {
++i
;
++j
;
}else if (i
> 0 && name
[i
-1] == typed
[j
]) {
++j
;
}else {
cout
<< i
<< " " << j
<< endl
;
return false;
}
}
return i
== n1
;
}
};
转载请注明原文地址: http://lol.8miu.com/read-15936.html