Short and Easy to understand Java Solution


  • 0
    E
    public class Solution {
        public boolean isSubsequence(String s, String t) {
            int indexs=0,indext=0;
            while(indexs<s.length() && indext<t.length()){
                if(s.charAt(indexs)==t.charAt(indext++)){
                    indexs++;
                }
            }
            return indexs==s.length()?true:false;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.