- Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathCheckStringSubsequence.java
More file actions
Latest commit
29 lines (25 loc) · 812 Bytes
/
Copy pathCheckStringSubsequence.java
File metadata and controls
29 lines (25 loc) · 812 Bytes
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
packagestrings.stringsubsequencecheck;
/**
* Return true if stringA is subsequence of stringB
* User: rpanjrath
* Date: 11/18/13
* Time: 4:36 PM
*/
publicclassCheckStringSubsequence {
privateCheckStringSubsequence() {
}
publicstaticbooleanisSubsequence(StringparentString, StringchildString) {
if (childString.isEmpty() || parentString.isEmpty() || childString.length() > parentString.length()) {
returnfalse;
}
for (inti = 0; i < parentString.length(); i++) {
if (parentString.charAt(i) == childString.charAt(0)) {
childString = childString.substring(1, childString.length());
}
if (childString.isEmpty()) {
returntrue;
}
}
returnfalse;
}
}