My one line java sulution


  • 0
    M

    public class Solution {
    public int findTargetSumWays(int[] nums, int S) {
    return proccess( nums, nums.length-1,S);
    }

    private int proccess(int[] nums,int pst,int s){
        return pst>0?proccess(nums,pst-1,s+nums[pst])+proccess(nums,pst-1,s-nums[pst]):Math.abs(s)==Math.abs(nums[0])? (nums[0]==0?2:1):0;
    }
    

    }


Log in to reply
 

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