You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given two strings `s` and `t`, return `true` if `s` is a subsequence of `t`, or `false` otherwise.
6
+
7
+
A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., `"ace"` is a subsequence of `"abcde"` while `"aec"` is not).
8
+
9
+
**Example 1:**
10
+
11
+
Input: `s = "abc"`, `t = "ahbgdc"`
12
+
Output: `true`
13
+
14
+
**Example 2:**
15
+
16
+
Input: `s = "axc"`, `t = "ahbgdc"`
17
+
Output: `false`
18
+
19
+
**Constraints:**
20
+
21
+
*`0 <= s.length <= 100`
22
+
*`0 <= t.length <= 10^4`
23
+
*`s` and `t` consist only of lowercase English letters.
24
+
25
+
## Solution
26
+
27
+
```python
28
+
defis_subsequence(self, s: str, t: str) -> bool:
29
+
"""
30
+
Check if string `s` is a subsequence of string `t`.
31
+
32
+
A subsequence is a sequence that can be derived from another sequence by deleting zero or more elements
33
+
without changing the order of the remaining elements.
34
+
35
+
:param self: The instance reference (for method implementation)
36
+
:param s: The potential subsequence string to check
37
+
:param t: The string in which to search for the subsequence
38
+
:return: True if `s` is a subsequence of `t`, False otherwise
0 commit comments