package com
.wsq
.leetcode
;
public class IsLongPressedName {
public boolean isLongPressedName(String name
, String typed
) {
int lenName
= name
.length();
int lenTyped
= typed
.length();
if(lenName
> lenTyped
){
return false;
}
int i
= 0;
int j
= 0;
while(i
< lenName
&& j
< lenTyped
){
char c
= name
.charAt(i
);
int n
= 0;
while(i
< lenName
&& name
.charAt(i
) == c
){
n
++;
i
++;
}
int m
= 0;
while(j
< lenTyped
&& typed
.charAt(j
) == c
){
m
++;
j
++;
}
if(n
> m
){
return false;
}
}
if(i
!= lenName
|| j
!= lenTyped
){
return false;
}
return true;
}
}
转载请注明原文地址: https://lol.8miu.com/read-20079.html