mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-18 03:31:58 +08:00
14 lines
289 B
Python
14 lines
289 B
Python
def is_subsequence(s, t):
|
|
"""
|
|
:type s: str
|
|
:type t: str
|
|
:rtype: bool
|
|
"""
|
|
if len(s) > len(t):
|
|
return False
|
|
matched_s = 0
|
|
for char in t:
|
|
if matched_s < len(s) and s[matched_s] == char:
|
|
matched_s += 1
|
|
return matched_s == len(s)
|