class Solution { public boolean canPartition(int[] nums) { int sum=0; for (int num:nums) sum+= num; if(sum % 2 == 1) return false; else{ sum /=2; int n=nums.length; // dp[i][j] 表示 如果我们取前i个数字,且背包容量为j的情况下,最多能放入多少东西 int dp[][]=new int[n][sum + 1]; // dp…