java 1ms solution


  • 7
    F
    public boolean isSubsequence(String s, String t) {
            int fromIndex = 0;
            for (char c : s.toCharArray()) {
                fromIndex = t.indexOf(c, fromIndex);
                if (fromIndex++ < 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.