Super Easy 5 line Java Solution!!!


  • 0
    C
    public class Solution {
        public boolean isSubsequence(String s, String t) {
            int j=-1;
            for(int i=0;i<s.length();i++)
            {
                j=t.indexOf(s.charAt(i),j+1);
                if(j==-1) return false;
            }
            return true;
        }
    }
    

Log in to reply
 

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