Guest User

Untitled

a guest
Apr 25th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. class Solution {
  2. public boolean isSubsequence(String s, String t) {
  3. char[] arr = s.toCharArray();
  4. int start = 0;
  5.  
  6. for (char c : arr) {
  7. boolean found = false;
  8.  
  9. for (int i = start; i < t.length(); i++) {
  10. if (c == t.charAt(i)) {
  11. found = true;
  12. start = i + 1;
  13. break;
  14. }
  15. }
  16.  
  17. if (!found) return false;
  18. }
  19.  
  20. return true;
  21. }
  22. }
Add Comment
Please, Sign In to add comment