very easy java solution


  • 1
    F
        public boolean isSubsequence(String s, String t) {
            int idx = 0;
            for (char c : s.toCharArray()) {
                idx = t.indexOf(c, idx);
                if (idx++ < 0) {
                    return false;
                }
            }
            return true;
        }

Log in to reply
 

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