94 - Target Sum - Dynamic Programming approach 2

@Rishi Srivastava Pseudo code: int findTargetSumWays(int[] nums, int target, int index, int total, Map memo) { // key=index~total, value if (index == ) { return (total == target) ? 1 : 0; } String key = index “~“ total; if (!(key)) { int value = findTargetSumWays(nums, target, index 1, total nums[index], memo) findTargetSumWays(nums, target, index 1, total - nums[index], memo); (key, value); } return (key); } Github: Leetcode:
Back to Top