diff --git "a/problems/0718.346円234円200円351円225円277円351円207円215円345円244円215円345円255円220円346円225円260円347円273円204円.md" "b/problems/0718.346円234円200円351円225円277円351円207円215円345円244円215円345円255円220円346円225円260円347円273円204円.md" index 18cc02407f..272cf2b2a4 100644 --- "a/problems/0718.346円234円200円351円225円277円351円207円215円345円244円215円345円255円220円346円225円260円347円273円204円.md" +++ "b/problems/0718.346円234円200円351円225円277円351円207円215円345円244円215円345円255円220円346円225円260円347円273円204円.md" @@ -536,6 +536,29 @@ function findLength(nums1: number[], nums2: number[]): number { }; ``` +Rust: + +> 滚动数组 + +```rust +impl Solution { + pub fn find_length(nums1: Vec, nums2: Vec) -> i32 { + let (mut res, mut dp) = (0, vec![0; nums2.len()]); + + for n1 in nums1 { + for j in (0..nums2.len()).rev() { + if n1 == nums2[j] { + dp[j] = if j == 0 { 1 } else { dp[j - 1] + 1 }; + res = res.max(dp[j]); + } else { + dp[j] = 0; + } + } + } + res + } +} +```

AltStyle によって変換されたページ (->オリジナル) /