class Solution {
public:
bool isLongPressedName(string name
, string typed
) {
if (name
.empty() || typed
.empty() || name
.size() > typed
.size())
return name
== typed
;
name
= "#" + name
+ "#";
typed
= "#" + typed
;
int i
, j
;
for (i
= 0, j
= 0; i
< name
.size() && j
< typed
.size(); j
++) {
if (name
[i
] == typed
[j
]) i
++;
else if (name
[i
- 1] != typed
[j
]) return false;
}
return name
[i
] == '#';
}
};
转载请注明原文地址: https://lol.8miu.com/read-20784.html