416. Partition Equal Subset Sum Medium

@problem@discussion
#Array#Dynamic Programming



1/**
2 * [416] Partition Equal Subset Sum
3 *
4 * Given a non-empty array nums containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.
5 *  
6 * Example 1:
7 * 
8 * Input: nums = [1,5,11,5]
9 * Output: true
10 * Explanation: The array can be partitioned as [1, 5, 5] and [11].
11 * 
12 * Example 2:
13 * 
14 * Input: nums = [1,2,3,5]
15 * Output: false
16 * Explanation: The array cannot be partitioned into equal sum subsets.
17 * 
18 *  
19 * Constraints:
20 * 
21 * 	1 <= nums.length <= 200
22 * 	1 <= nums[i] <= 100
23 * 
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/partition-equal-subset-sum/
28// discuss: https://leetcode.com/problems/partition-equal-subset-sum/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33    pub fn can_partition(nums: Vec<i32>) -> bool {
34        false
35    }
36}
37
38// submission codes end
39
40#[cfg(test)]
41mod tests {
42    use super::*;
43
44    #[test]
45    fn test_416() {
46    }
47}
48


Back
© 2025 bowen.ge All Rights Reserved.