Long Pressed Name LeetCode solution in C++

1
class Solution {
2
public:
3
bool isLongPressedName(string name, string typed) {
4
int j = 0, i = 0;
5
for (; i < name.length() && j < typed.length(); i++) {
6
if (name[i] != typed[j++]) return false;
7

8
if (i < name.length() && name[i] != name[i + 1]) {
9
while (j < typed.length() && typed[j] == name[i]) j++;
10
}
11
}
12

13
return (i == name.length() && j == typed.length());
14
}
15
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0