给定两个字符串 S 和 T ,判断 S 是否是 T 的子序列。
即是否可以从 T 删除一些字符转换成 S。
数据范围: , ,保证字符串中仅含有小写字母
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param S string字符串 * @param T string字符串 * @return bool布尔型 */ pub fn isSubsequence(&self, S: String, T: String) -> bool { // write code here self.check(&S[..], &T[..]) } fn check(&self, s: &str, t: &str) -> bool { if s == "" && t == "" {return true} if s == "" {return false} if t == "" {return false} if s[0 ..= 0] == t[0 ..= 0] { self.check(&s[1 ..], &t[1 ..]) } else { self.check(s, &t[1 ..]) } } }