Skip to content

Commit d6dadfe

Browse files
authored
Create Is Subsequence - Leetcode 392.py
1 parent c1f7e13 commit d6dadfe

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Is Subsequence - Leetcode 392.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution:
2+
def isSubsequence(self, s: str, t: str) -> bool:
3+
S = len(s)
4+
T = len(t)
5+
if s == '': return True
6+
if S > T: return False
7+
8+
j = 0
9+
for i in range(T):
10+
if t[i] == s[j]:
11+
if j == S-1:
12+
return True
13+
j += 1
14+
15+
return False
16+
# Time: O(T)
17+
# Space: O(1)

0 commit comments

Comments
 (0)