cool dude..really a good explanation for a beginner like me..thnx
@K_SE_SaketVerma8 ай бұрын
Wonderful explanation , keep up the good work !
@nkvs1248 Жыл бұрын
Oooooo Required a lot of patience , Nice one......!!!
@HandyEngineering Жыл бұрын
nit: you do not need to sort vector v before you push items into the map mp2 (map is sorted anyway and this is why the code works)
@kashishchawla2754 Жыл бұрын
Can you please please make a video f question number of 1994 the number of good subsets , I am not getting the overall concept and nobody solves such tough questions on youtube except you! It would be of great help to all of us!!! Thanks!
@shabnamhaque378421 күн бұрын
if returning 1 in base case confuses you u may try thisclass Solution { public: int dfs(vector&a,int ind,int k,unordered_map&mp){ if(ind==a.size()) return 0;//empty subset int taken=0,nottaken=0; if(mp[a[ind]-k]==0 and mp[a[ind]+k]==0) { mp[a[ind]]++; taken=1+dfs(a,ind+1,k,mp); mp[a[ind]]--; //take } nottaken=dfs(a,ind+1,k,mp); return taken+nottaken; } int beautifulSubsets(vector& nums, int k) { //make all subsets and count the good ones - brute force // make only good subsets int n=nums.size(); unordered_mapmp; int ans=dfs(nums,0,k,mp); return ans; } };
@VarunSharma-xd8xd8 ай бұрын
watched 2 times but i dont know what u did in the dp approach
@cenacr007 Жыл бұрын
I don't know why by map.find() wasn't working at all for me, whether I used set or map.
@bhumikanayyar23008 ай бұрын
why not use set in backtracking approach as we just care if nums[i]-k /nums[i]+k exists or not?
@kergeysarjakin55928 ай бұрын
bro 1 and 4 itself can;t be taken bcoz 4-1=3 at 7:30
@ARYANMITTAL8 ай бұрын
Yaa yaa yaa, true true bro
@killadasatyaaditya5960 Жыл бұрын
Can you explain why prevNotTaken is inititalized with 1 and prevTaken with 0
@ARYANMITTAL Жыл бұрын
As initially we have empty subset
@GauravDuseja-t6q8 ай бұрын
I was not able to implement backtracking proble what to do bhaiya
@ARYANMITTAL8 ай бұрын
Have you watched backtracking crash course bro?? 🫂
@Munchen8886 ай бұрын
Look. You have two options: take or not take an element. If you not take you just go further -> func(idx + 1); else take you should make a check if such element in defaultdict (dict) or not . If not you place the element in defaultdict and go further. But when you return you should remove from dict. Set in initial state .
@satvrii Жыл бұрын
Striver 2.0
@ArnabBhadra028 ай бұрын
your vives match with striver
@RohitKumar-cv7qb Жыл бұрын
way of teaching is good, but that extra effort we require to keep attention on English, that's really irritating
@hasii362638 ай бұрын
man this is a very bad explanation.
@prashantdubey9984 Жыл бұрын
Is it necessary to move your hands ?? It's really irritating
@tonytonychopper2485 Жыл бұрын
"irritating" is a strong word. If you say "It would be less distracting if you reduce the hand movement", that might deliver what you wanted to say without hurting his feelings.