Dsa
Dynamic Programming
Easy
Minimum Sum Partition
You are given an array of integers `nums`. Your task is to partition the array into two subsets such that the difference of their sums is minimized. Implement a function that reads the array and prints the minimum possible difference between the two subset sums.
Input format:
- The first line contains an integer `n` (1 ≤ n ≤ 100).
- The second line contains `n` space-separated integers representing the `nums` array (1 ≤ |nums[i]| ≤ 100).
Output format:
- Print a single integer, the minimum difference between the two subset sums.
Example:
Input:
4
1 6 11 5
Output:
1
(The two subsets can be [1, 5, 6] and [11], difference is 1).
Key concepts
dynamic_programmingsubset_sumarray
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now