Update 0392.判断子序列.md about rust
This commit is contained in:
parent
eb632c6183
commit
eb9c4e647b
|
|
@ -258,9 +258,25 @@ func isSubsequence(s string, t string) bool {
|
|||
}
|
||||
```
|
||||
|
||||
Rust:
|
||||
|
||||
|
||||
|
||||
```rust
|
||||
impl Solution {
|
||||
pub fn is_subsequence(s: String, t: String) -> bool {
|
||||
let mut dp = vec![vec![0; t.len() + 1]; s.len() + 1];
|
||||
for (i, char_s) in s.chars().enumerate() {
|
||||
for (j, char_t) in t.chars().enumerate() {
|
||||
if char_s == char_t {
|
||||
dp[i + 1][j + 1] = dp[i][j] + 1;
|
||||
continue;
|
||||
}
|
||||
dp[i + 1][j + 1] = dp[i + 1][j]
|
||||
}
|
||||
}
|
||||
dp[s.len()][t.len()] == s.len()
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<p align="center">
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
|
|
|
|||
Loading…
Reference in New Issue