class Solution {
public boolean isLongPressedName(String name, String typed) {
int n = 0;
int nameLen = name.length();
int typedLen = typed.length();
for (int t = 0; t < typedLen; t++) {
if (n < nameLen && name.charAt(n) == typed.charAt(t)) {
n++;
} else if (t > 0 && typed.charAt(t-1) != typed.charAt(t)) {
return false;
}
}
return n == nameLen;
}
}