718. Maximum Length of Repeated Subarray Medium

@problem@discussion
#Array#Binary Search#Dynamic Programming#Sliding Window#Rolling Hash#Hash Function



1/**
2 * [718] Maximum Length of Repeated Subarray
3 *
4 * Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays.
5 *  
6 * Example 1:
7 * 
8 * Input: nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7]
9 * Output: 3
10 * Explanation: The repeated subarray with maximum length is [3,2,1].
11 * 
12 * Example 2:
13 * 
14 * Input: nums1 = [0,0,0,0,0], nums2 = [0,0,0,0,0]
15 * Output: 5
16 * 
17 *  
18 * Constraints:
19 * 
20 * 	1 <= nums1.length, nums2.length <= 1000
21 * 	0 <= nums1[i], nums2[i] <= 100
22 * 
23 */
24pub struct Solution {}
25
26// problem: https://leetcode.com/problems/maximum-length-of-repeated-subarray/
27// discuss: https://leetcode.com/problems/maximum-length-of-repeated-subarray/discuss/?currentPage=1&orderBy=most_votes&query=
28
29// submission codes start here
30
31impl Solution {
32    pub fn find_length(nums1: Vec<i32>, nums2: Vec<i32>) -> i32 {
33        0
34    }
35}
36
37// submission codes end
38
39#[cfg(test)]
40mod tests {
41    use super::*;
42
43    #[test]
44    fn test_718() {
45    }
46}
47


Back
© 2025 bowen.ge All Rights Reserved.