# Leetcode 392. Is Subsequence ## 題解 ### Two pointers ```python class Solution: def isSubsequence(self, s: str, t: str) -> bool: # Brute force # Time complexity: O(t+s) # Space complexity: O(1) tn = len(t) sn = len(s) cs = sn - 1 ct = tn - 1 while 0 <= ct < tn and 0 <= cs < sn: st = t[ct] top_s = s[cs] if st == top_s: cs -= 1 ct -= 1 return cs == -1 ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up