1013. Partition Array Into Three Parts With Equal Sum Easy

@problem@discussion
#Array#Greedy



1/**
2 * [1013] Partition Array Into Three Parts With Equal Sum
3 *
4 * Given an array of integers arr, return true if we can partition the array into three non-empty parts with equal sums.
5 * Formally, we can partition the array if we can find indexes i + 1 < j with (arr[0] + arr[1] + ... + arr[i] == arr[i + 1] + arr[i + 2] + ... + arr[j - 1] == arr[j] + arr[j + 1] + ... + arr[arr.length - 1])
6 *  
7 * Example 1:
8 * 
9 * Input: arr = [0,2,1,-6,6,-7,9,1,2,0,1]
10 * Output: true
11 * Explanation: 0 + 2 + 1 = -6 + 6 - 7 + 9 + 1 = 2 + 0 + 1
12 * 
13 * Example 2:
14 * 
15 * Input: arr = [0,2,1,-6,6,7,9,-1,2,0,1]
16 * Output: false
17 * 
18 * Example 3:
19 * 
20 * Input: arr = [3,3,6,5,-2,2,5,1,-9,4]
21 * Output: true
22 * Explanation: 3 + 3 = 6 = 5 - 2 + 2 + 5 + 1 - 9 + 4
23 * 
24 *  
25 * Constraints:
26 * 
27 * 	3 <= arr.length <= 5 * 10^4
28 * 	-10^4 <= arr[i] <= 10^4
29 * 
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum/
34// discuss: https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39    pub fn can_three_parts_equal_sum(arr: Vec<i32>) -> bool {
40        false
41    }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_1013() {
52    }
53}
54


Back
© 2025 bowen.ge All Rights Reserved.