알고리즘 문제풀기

392. Is Subsequence

yjam 2019. 11. 27. 12:51

https://leetcode.com/problems/is-subsequence/

 

Is Subsequence - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

 

class Solution(object):  
    def isSubsequence(self, s, t):  
        """  
        :type s: str  
        :type t: str  
        :rtype: bool  
        """  

        count = 0  

        for i in range(0, len(t), 1):  

            if count < len(s) and s[count] == t[i]:  
                count+=1  

        if count == len(s):  
            return True  
        else:  
            return False