官方题解https://leetcode-cn.com/problems/long-pressed-name/solution/chang-an-jian-ru-by-leetcode-solution/
class Solution {
public:
bool isLongPressedName(string name, string typed) {
int i=0, j=0, len1=name.size(), len2=typed.size();
while(j<len2){
if(i<len1 && name[i]==typed[j]){ //注意i<len1
++i,++j;
}else if(j>0 && typed[j]==typed[j-1]){ //注意j>0
++j;
}else return false;
}
return i==len1; //j走完了,i也走完了,true
//j走完了,i没走完,说明typed少了最后的字符,false
}
};