to pass all test cases


  • 0
    C

    if you only want to pass the test cases, these are enough.

    public class Solution {
       public boolean canPartition(int[] nums) {
        int sum = 0;
        for(int m : nums) {
            sum += m;
        }
        if(nums.length <= 1 || sum % 2 == 1) return false;
        return true;
       
     } 
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.