We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 87bd67f commit 7a6ffbbCopy full SHA for 7a6ffbb
two-pointers/392_is_subsequence/README.md
@@ -54,3 +54,17 @@ def is_subsequence(self, s: str, t: str) -> bool:
54
55
* **Time Complexity:** $O(n)$
56
* **Space Complexity:** $O(1)$
57
+
58
+## Explanation of the Solution
59
60
+1. Initialization:
61
+ * `s_pointer` starts at 0 (points to the current character in s being checked).
62
+ * `s_length` stores the length of s.
63
+2. Edge Case Handling:
64
+ * If `s` is empty, it’s trivially a subsequence of any string (including empty `t`), so return `True`.
65
+3. Iterate Through `t`:
66
+ * For each character in `t` (using `t_pointer`):
67
+ * If the current character in `t` matches the current character in `s` (at `s_pointer`), move `s_pointer` forward.
68
+ * If `s_pointer` reaches the end of `s` (`s_pointer == s_length`), all characters of s were found in order → return `True`.
69
+4. Final Check:
70
+ * If the loop ends without `s_pointer` reaching `s_length`, `s` is not a subsequence → return `False`.
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments