Skip to content

Latest commit

 

History

History
20 lines (20 loc) · 457 Bytes

File metadata and controls

20 lines (20 loc) · 457 Bytes
class Solution {
    public boolean isSubsequence(String s, String t) {
        if(s.length() == 0){
            return true;
        }
        int indexS = 0, indexT = 0;
        while(indexT < t.length()){
            if(t.charAt(indexT) == s.charAt(indexS)){
                indexS++;
            }
            indexT++;
            if(indexS == s.length()){
                return true;
            }
        }
        return false;
    }
}