Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public boolean isSubsequence(String s, String t) {
- if (s == null || s.length() == 0) return true;
- int i = 0;
- int j = 0;
- while (i < s.length() && j < t.length()) {
- if (s.charAt(i) == t.charAt(j)) {
- i++;
- if (i == s.length()) return true;
- }
- j++;
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment