698. Partition to K Equal Sum Subsets Medium
1/**
2 * [698] Partition to K Equal Sum Subsets
3 *
4 * Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal.
5 *
6 * Example 1:
7 *
8 * Input: nums = [4,3,2,3,5,2,1], k = 4
9 * Output: true
10 * Explanation: It is possible to divide it into 4 subsets (5), (1, 4), (2,3), (2,3) with equal sums.
11 *
12 * Example 2:
13 *
14 * Input: nums = [1,2,3,4], k = 3
15 * Output: false
16 *
17 *
18 * Constraints:
19 *
20 * 1 <= k <= nums.length <= 16
21 * 1 <= nums[i] <= 10^4
22 * The frequency of each element is in the range [1, 4].
23 *
24 */
25pub struct Solution {}
26
27// problem: https://leetcode.com/problems/partition-to-k-equal-sum-subsets/
28// discuss: https://leetcode.com/problems/partition-to-k-equal-sum-subsets/discuss/?currentPage=1&orderBy=most_votes&query=
29
30// submission codes start here
31
32impl Solution {
33 pub fn can_partition_k_subsets(nums: Vec<i32>, k: 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_698() {
46 }
47}
48
Back
© 2025 bowen.ge All Rights Reserved.