392. Is Subsequence Easy
1/**
2 * [392] Is Subsequence
3 *
4 * Given two strings s and t, return true if s is a subsequence of t, or false otherwise.
5 * 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 "<u>a</u>b<u>c</u>d<u>e</u>" while "aec" is not).
6 *
7 * Example 1:
8 * Input: s = "abc", t = "ahbgdc"
9 * Output: true
10 * Example 2:
11 * Input: s = "axc", t = "ahbgdc"
12 * Output: false
13 *
14 * Constraints:
15 *
16 * 0 <= s.length <= 100
17 * 0 <= t.length <= 10^4
18 * s and t consist only of lowercase English letters.
19 *
20 *
21 * Follow up: Suppose there are lots of incoming s, say s1, s2, ..., sk where k >= 10^9, and you want to check one by one to see if t has its subsequence. In this scenario, how would you change your code?
22 */
23pub struct Solution {}
24
25// problem: https://leetcode.com/problems/is-subsequence/
26// discuss: https://leetcode.com/problems/is-subsequence/discuss/?currentPage=1&orderBy=most_votes&query=
27
28// submission codes start here
29
30impl Solution {
31 pub fn is_subsequence(s: String, t: String) -> bool {
32 false
33 }
34}
35
36// submission codes end
37
38#[cfg(test)]
39mod tests {
40 use super::*;
41
42 #[test]
43 fn test_392() {
44 }
45}
46
Back
© 2025 bowen.ge All Rights Reserved.