Skip to content

Commit df0a087

Browse files
authored
Create Append Characters to String to Make Subsequence.java
1 parent 15b9075 commit df0a087

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public int appendCharacters(String s, String t) {
3+
int idxS = 0;
4+
int idxT = 0;
5+
while (idxS < s.length() && idxT < t.length()) {
6+
if (s.charAt(idxS) == t.charAt(idxT)) {
7+
idxT++;
8+
}
9+
idxS++;
10+
}
11+
return idxT == t.length() ? 0 : t.length() - idxT;
12+
}
13+
}

0 commit comments

Comments
 (0)