Skip to content

Commit 7f28ff7

Browse files
authored
Merge pull request #1250 from tharunkanna14/patch-2
Create 0392_is_subsequence.java
2 parents e7fbd4b + 52390d3 commit 7f28ff7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

java/0392_is_subsequence.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public boolean isSubsequence(String s, String t) {
3+
int i = 0, j = 0;
4+
while (i < s.length() && j < t.length()) {
5+
if (s.charAt(i) == t.charAt(j)) {
6+
i += 1;
7+
}
8+
j += 1;
9+
}
10+
if (i == s.length()) {
11+
return true;
12+
} else {
13+
return false;
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)