forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_392.java
More file actions
25 lines (23 loc) · 706 Bytes
/
_392.java
File metadata and controls
25 lines (23 loc) · 706 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
package com.fishercoder.solutions;
public class _392 {
public static class Solution1 {
public boolean isSubsequence(String s, String t) {
int left = 0;
for (int i = 0; i < s.length(); i++) {
boolean foundI = false;
int j = left;
for (; j < t.length(); j++) {
if (s.charAt(i) == t.charAt(j)) {
left = j + 1;
foundI = true;
break;
}
}
if (j == t.length() && !foundI) {
return false;
}
}
return true;
}
}
}