-
-
Notifications
You must be signed in to change notification settings - Fork 291
Expand file tree
/
Copy path925.java
More file actions
54 lines (54 loc) · 1.85 KB
/
925.java
File metadata and controls
54 lines (54 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
__________________________________________________________________________________________________
sample 0 ms submission
class Solution {
public boolean isLongPressedName(String name, String typed) {
int lenN=name.length(), lenT=typed.length();
int start=0;
for(int i=0; i<lenT; i++) {
if(typed.charAt(i)==name.charAt(start)) {
start++;
if(start==lenN) return true;
}
}
return false;
}
}
__________________________________________________________________________________________________
sample 35400 kb submission
class Solution {
public boolean isLongPressedName(String name, String typed) {
int typedwrong=0;
if(name.charAt(0)!=typed.charAt(0))
return false;
if(name.charAt(name.length()-1)!=typed.charAt(typed.length()-1))
return false;
if(name.equals(typed))
return true;
else
{
if(name.length()>=typed.length())
return false;
else
{
for(int i=0;i<name.length();i++)
{
if(typed.length()<=(i+typedwrong))
return false;
if(name.charAt(i)==typed.charAt(i+typedwrong))
continue;
else if(name.charAt(i)!=typed.charAt(i+typedwrong))
{
if(typed.charAt(i+typedwrong)==typed.charAt(i+typedwrong-1))
{
typedwrong++;
i--;
}
else return false;
}
}
return true;
}
}
}
}
__________________________________________________________________________________________________