[LeetCode] 392. Is Subsequence(Kotlin)

0

LeetCode

목록 보기
25/58
post-thumbnail

[LeetCode] 392. Is Subsequence(Kotlin)

풀이

class Solution {
    fun isSubsequence(s: String, t: String): Boolean {
        if(s == "") return true
        if(t.length < s.length) return false

        var sIndex = 0
        var tIndex = 0
        while(tIndex < t.length){
            if(t[tIndex] == s[sIndex]){
                tIndex++
                sIndex++
                if(sIndex == s.length) return true
            }
            else tIndex++
        }
        return false
    }
}
profile
Be able to be vulnerable, in search of truth

0개의 댓글