1131. Maximum of Absolute Value Expression Medium

@problem@discussion
#Array#Math



1/**
2 * [1131] Maximum of Absolute Value Expression
3 *
4 * Given two arrays of integers with equal lengths, return the maximum value of:
5 * 
6 * |arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j|
7 * 
8 * where the maximum is taken over all 0 <= i, j < arr1.length.
9 *  
10 * Example 1:
11 * 
12 * Input: arr1 = [1,2,3,4], arr2 = [-1,4,5,6]
13 * Output: 13
14 * 
15 * Example 2:
16 * 
17 * Input: arr1 = [1,-2,-5,0,10], arr2 = [0,-2,-1,-7,-4]
18 * Output: 20
19 * 
20 *  
21 * Constraints:
22 * 
23 * 	2 <= arr1.length == arr2.length <= 40000
24 * 	-10^6 <= arr1[i], arr2[i] <= 10^6
25 * 
26 */
27pub struct Solution {}
28
29// problem: https://leetcode.com/problems/maximum-of-absolute-value-expression/
30// discuss: https://leetcode.com/problems/maximum-of-absolute-value-expression/discuss/?currentPage=1&orderBy=most_votes&query=
31
32// submission codes start here
33
34impl Solution {
35    pub fn max_abs_val_expr(arr1: Vec<i32>, arr2: Vec<i32>) -> i32 {
36        0
37    }
38}
39
40// submission codes end
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn test_1131() {
48    }
49}
50


Back
© 2025 bowen.ge All Rights Reserved.