No video

Perfect Squares | Bottom UP | Made Easy | Google | Leetcode 279

  Рет қаралды 3,629

codestorywithMIK

codestorywithMIK

Күн бұрын

Whatsapp Community Link : www.whatsapp.c...
This is the 86th Video of our Playlist "Dynamic Programming : Popular Interview Problems".
In this video we will try to solve a very good DP problem - Perfect Squares | Leetcode 279
We will solve it using Bottom Up because we have already solved this using Recursion + Memo in another video (Link below) :
• Perfect Squares | Why ...
We will be using the same Recursion + Memo code to convert it to Bottom Up.
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.
Problem Name : Perfect Squares | Leetcode 279
Company Tags : Google, Salesforce, Microsoft, Meta, Amazon
My solutions on Github(C++ & JAVA) : github.com/MAZ...
Leetcode Link : leetcode.com/p...
My Recursion Concepts Playlist : • Introduction | Recursi...
My DP Concepts Playlist : • Roadmap for DP | How t...
My Graph Concepts Playlist : • Graph Concepts & Qns -...
My GitHub Repo for interview preparation : github.com/MAZ...
Subscribe to my channel : / @codestorywithmik
Instagram : / codestorywithmik
Facebook : / 100090524295846
Twitter : / cswithmik
Approach Summary : The approach utilizes dynamic programming and an array t to store the minimum number of perfect squares required for each number from 0 to n. The algorithm iterates through each number, decomposing it into the sum of a perfect square and a remaining number. It calculates the minimum number of perfect squares needed for the current number based on the subproblem solutions. The final result is the minimum number of perfect squares required to sum up to the input n.
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
✨ Timelines✨
00:00 - Introduction
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #2024 #newyear

Пікірлер: 19
@codestorywithMIK
@codestorywithMIK 7 ай бұрын
Recursion + Memo - kzbin.info/www/bejne/kJPRaZykbM2jjrs
@Abhi_008
@Abhi_008 7 ай бұрын
Sir time & space complexity will be : TC : O(N * sqrt(N)) & SC : O(N) respectively Tabulation -> Recursive code copy paste: int tab(int n) { vector t(n+1, 0); for (int i = 1; i
@legendcreatz9783
@legendcreatz9783 7 ай бұрын
Bro can you please upload the basic concept of backtracking using Java...It is very confusing 🙏
@bhuppidhamii
@bhuppidhamii 7 ай бұрын
Earlier I also used to do DSA in Java, but after switching to cc, everything becomes so easy.
@Dettol_Vodka
@Dettol_Vodka 7 ай бұрын
​@@bhuppidhamiicc? Codechef? Or you're trynna say cpp
@bhuppidhamii
@bhuppidhamii 7 ай бұрын
@@Dettol_Vodka I mean CPP cc is a file extension of CPP files.
@ritesh031
@ritesh031 7 ай бұрын
Hello bhaiya Need a playlist that cover DSA from beginning like some easy concepts bcz I just want to start my DSA journey. So suggest some playlist or make it ❤
@Strawcontamination
@Strawcontamination 7 ай бұрын
Please solve more questions on backtracking
@oqant0424
@oqant0424 7 ай бұрын
U made bottom up so easy 💖💖
@codestorywithMIK
@codestorywithMIK 7 ай бұрын
I'm so glad! ❤️❤️🙏🙏
@user-ub2is4rs4x
@user-ub2is4rs4x 7 ай бұрын
Thanks a lot for making Graph and DP easy 👌🏻
@theOmKumar
@theOmKumar 7 ай бұрын
came up with bottom up myself for the first time! but it's looking a bit messy also using sqrt() 😅 /* // DP + memoisation class Solution { public: int dp[10001]; int solve (int n){ if (dp[n] != -1) return dp[n]; int root = sqrt(n); if(root * root == n) return 1; int minOccurence = INT_MAX; for(int i = root; i >= 1 ; i--){ minOccurence = min(minOccurence,1 + solve(n-(i*i))); } return dp[n] = minOccurence; } int numSquares(int n) { memset(dp,-1,sizeof(dp)); return solve(n); } }; */ class Solution { public: int numSquares(int n) { vector dp(n + 1,0); dp[0] = 0; for (int j = 1; j = 1; i--) { minOccurrence = min(minOccurrence, 1 + dp[j - (i * i)]); } dp[j] = minOccurrence; } } return dp[n]; } };
@pradeepranjan8226
@pradeepranjan8226 7 ай бұрын
Recursion + Memo will not work now as they have more Test cases. only solution is Bottom-up. Hint: This is variant of Coin change problem.
@tutuimam3381
@tutuimam3381 7 ай бұрын
❤❤❤❤❤❤
@vanshjain5960
@vanshjain5960 7 ай бұрын
Bhai aap atcoder dp contest k solution post karo yrr😭😭
@shabananoor9423
@shabananoor9423 7 ай бұрын
❤❤
@dayashankarlakhotia4943
@dayashankarlakhotia4943 7 ай бұрын
class Solution { public int numSquares(int n){ int[]dp=new int[n+1]; Arrays.fill(dp,n); dp[0]=0; dp[1]=1; for(int i=2;i
@mohdtalib7350
@mohdtalib7350 7 ай бұрын
private int numSquaresDp(int n) { int[] dp = new int[n+1]; for(int i =1; i
279. Perfect Squares - Day 27/30 Leetcode June Challenge
9:37
Programming Live with Larry
Рет қаралды 290
Фейковый воришка 😂
00:51
КАРЕНА МАКАРЕНА
Рет қаралды 5 МЛН
Perfect Squares - Dynamic Programming - Leetcode 279 - Python
15:12
Dynamic Programming Mindset for Codeforces ft. CF2003F
17:44
Perfect Squares | LeetCode 279 | C++, Java, Python
18:03
Knowledge Center
Рет қаралды 10 М.