112ms JavaScript Solution, beats 100%


  • 0
    var isSubsequence = function(s, t) {
        for (var i = 0; i < s.length; i++) {
            var index = t.indexOf(s.charAt(i))
            t = t.slice(index + 1)
            if (index == -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.