@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);
}
Time complexity: O(n)
Space complexity: O(n)
Github:
Leetcode
1 view
4310
1542
2 weeks ago 00:46:56 1
Технофеодали захоплюють світ – Ігор Розкладай #шоубісики
2 weeks ago 00:04:32 1
Новые Апокалиптические кадры в Калифорнии,! Лесной пожар опустошает Лос-Анджелес
2 weeks ago 00:43:40 2
СВЕРХВАЖНО! ПОБЕДА ЭТО ЗВУК САМОЙ ЖИЗНИ⚡️@novoe_probujdene_chelovchestva