Perfect Sum Problem DP solution Recursion Memoization & Top Down Approach Hello World
Vložit
- čas přidán 7. 09. 2024
- In this video on Recursion and DP, part of the DATA STRUCTURE & ALGORITHM series, we will solve a Problem stated as the "Perfect Sum Problem" by using Recursion and Memoization in DP
Join My Telegram channel for more Updates: telegram.me/he...
complete DSA preparation: github.com/Pri...
Our comprehensive courses on Competitive Programming, Data Structures, and Algorithms enhance your programming skills. Check out our Channel's Full Playlist to elevate your coding abilities!
----------------------------------------------------------------------------------------
🟠 Perfect Sum Problem
Given an array arr[] of non-negative integers and an integer sum, the task is to count all subsets of the given array with a sum equal to a given sum. Note: The answer can be very large, so, output answer modulo 109+7
Input: N = 6, arr[] = {2, 3, 5, 6, 8, 10} sum = 10
Output: 3
Explanation: {2, 3, 5}, {2, 8}, {10}
🟣 Perfect Sum Problem: practice.geeks...
🟢 Code in this video: github.com/Pri...
🟡 Pdf in this video: github.com/Pri...
----------------------------------------------------------------------------------------
Follow me on:
💼 LinkedIn► / iamprince
📷 Instagram► / helloworldbyprince
🐦 Twitter► / prince_king_
📲 Telegram► telegram.me/he...
📘 Facebook► / helloworldofficials
----------------------------------------------------------------------------------------
►Our Playlists on:-
🔥 Tree: • Tree Data Structure & ...
🔥 Stack & Queue: • Stack & Queue Data Str...
🔥 Hashing: • Hashing Data Structure...
🔥 Graph: • Graph Data Structure &...
🔥 Matrix: • Matrix (Multidimension...
🔥 Recursion & DP: • Recursion
🔥 Heap: • Heap Data Structure & ...
🔥 Linked List: • Linked List Data Struc...
🔥 STL: • Standard Template Libr...
🔥 Leetcode: • LeetCode Solutions And...
🔥Competitive Programming: • Full course in Competi...
🔥 C++ Full Course: • C++ full Course in HINDI
🔥 Algorithms: • L-01 || Prefix Sum Arr...
🔥 Data Structure: • Data Structures with C...
------------------------------------------------------------------------
🌟 Please leave a LIKE ❤️ and SUBSCRIBE for more AMAZING content! 🌟
✨ Tags ✨
Perfect Sum Problem
Perfect Sum Problem gfg
Perfect Sum Problem coding ninjas
Perfect Sum Problem take u forward
Perfect Sum Problem dynamic programming
Perfect Sum Problem youtube
Perfect Sum Problem Hindi
dynamic programming problems
dynamic programming playlist
dynamic programming strive
dynamic programming adithya varma
dynamic programming playlist c++
dynamic programming take u forward
dynamic programming leetcode
dp playlist leetcode
Recursive solution
Recursion programming
Recursive Function
Programming tutorials
Coding challenges
Number reversal
Math problems
Algorithm design
Data structures and algorithms
Computer science education
Software development
Beginner programming
complete recursion playlist
Coding tips and tricks
C++ programming
Coding projects
Problem-solving techniques
C++ programming
Data structures and algorithms
Recursive functions
Recursive approach
Computer science
Programming tutorials
Educational videos
Beginner programming
Coding challenges
Software engineering
Algorithm Design
C++ Programming Basics
C++ Syntax
C++ Functions
Recursive Functions
Coding Tutorials
Programming languages
Computer science
Computer programming
Recursive functions
Software engineering
Hello World
programming
coding
software development
beginner programming
coding for beginners
programming tips and tricks
software engineering
coding tutorials
web development
programming languages
coding challenges
coding projects
software design
coding bootcamps
coding resources
C++ syntax
Educational videos
solve leetcode problems
solving leetcode problems c++
solving leetcode questions
solving all leetcode problems
how to solve leetcode questions
solve the equation leetcode
#dynamicprogramming #geeksforgeeks #programming
Comment "#Princebhai" if you read this 😉😉
Thanks a lot for the clearing of initialization concept. You gave the only video which clarified it. All other videos are using top-down approach which I am not comfortable in. Super grateful!
Instead of so many base cases we can simply initialise the 2D array like this and then replace the base cases with the fist line that you've written:
double [,] dp = new double [n+1, sum+1];
dp[0,0] = 1;
for (int j=1; j
great explanation , thanks
much helpful vid sir!
thank you brother
bhaIyya i want to meet u, im studying in bits pilani and i came to ranchi during summer vacations, i heard u also live in ranchi, big fan, please reply to this comment!
thank you sir...
Most welcome
Thanks sir
Welcome
Top Down Approach :
vector dp(n+1,vector(sum+1,-1));
int zero=0;
for(int i=0;i
recursive solutin bana but optimization nahi howa
int helper(int i,int arr[], int n, int sum,vector &dp){
//base case
if(i>=n){
if(sum == 0){
return 1;
}else return 0;
}
if(dp[i][sum] != -1){
return dp[i][sum];
}
int take=0;
if(arr[i]
bhai samajh nhi aaya