494. Target Sum | Leetcode Daily Challenge

  Рет қаралды 190

Ethos Typos

Ethos Typos

Күн бұрын

Пікірлер: 2
@touhidiutcse
@touhidiutcse 20 күн бұрын
Thanks so much for covering recursive approach alongside optimizing it by memoization & dynamic programming, Wow!
@newbie6449
@newbie6449 20 күн бұрын
my recusive solution class Solution { int tryAllWays(int index,int &cnt,vector& nums,int sum,int target) { if(index==nums.size()) { if(sum==target) { cnt+=1; return cnt; } return cnt; } // sum+=nums[index]; tryAllWays(index+1,cnt,nums,sum+nums[index],target); tryAllWays(index+1,cnt,nums,sum-nums[index],target); return cnt; } public: int findTargetSumWays(vector& nums, int target) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int cnt=0; return tryAllWays(0,cnt,nums,0,target); } };
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
How a Blind Mathematician Became the World's Greatest
16:31
Newsthink
Рет қаралды 157 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Rust Functions Are Weird (But Be Glad)
19:52
Logan Smith
Рет қаралды 147 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 733 М.
983. Minimum Cost For Tickets | Leetcode Daily Challenge
17:21
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 196 М.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 341 М.
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН