Partition in K Subsets | Recursion & Backtracking | Code and Implementation

  Рет қаралды 36,034

Pepcoding

Pepcoding

Күн бұрын

Пікірлер: 84
@sharuk3545
@sharuk3545 3 жыл бұрын
just one word for you sir legend .. your logic to solve the question is awesomeee
@Pepcoding
@Pepcoding 3 жыл бұрын
Thankyou beta for such kind words. Keep watching and keep learning😊
@sharuk3545
@sharuk3545 3 жыл бұрын
@@Pepcoding thnks sir i recommended your videos my senior as well as my junior
@CobraAnkit
@CobraAnkit 11 ай бұрын
Sir, you should analyze the code of the question.
@vishwashdwivedi9469
@vishwashdwivedi9469 4 жыл бұрын
Great work Sir ... Appreciable work !
@Pepcoding
@Pepcoding 4 жыл бұрын
Thankyou beta! I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem. If you like our efforts, will you like to write a few words about us here - g.page/Pepcoding/review?rc
@Sunny-qq6un
@Sunny-qq6un 2 жыл бұрын
thank you very very much sir, I have been stuck in this problem for 1 day, thanks a lot sir
@Pepcoding
@Pepcoding 2 жыл бұрын
Happy to help. For better experience and well organised content sign up on nados.io And for being updated follow us on Instagram instagram.com/pepcoding/
@Now_I_am_all_fired_up
@Now_I_am_all_fired_up 2 жыл бұрын
Always :--- Love u Sir
@_hulk748
@_hulk748 2 жыл бұрын
thankyou sir❤❤🙏🙏
@nishthagoyal5018
@nishthagoyal5018 4 жыл бұрын
You explain in a very nice way👍
@Pepcoding
@Pepcoding 4 жыл бұрын
Thanks and welcome
@kunalchandra9869
@kunalchandra9869 3 жыл бұрын
Shakespeare of recursion😎!
@Pepcoding
@Pepcoding 3 жыл бұрын
Haha Keep learning, Keep growing and keep loving Pepcoding!😊
@shubhamagarwal2998
@shubhamagarwal2998 3 жыл бұрын
awesome details and explanation sir
@Pepcoding
@Pepcoding 3 жыл бұрын
Glad to know that you liked the content and thank you for appreciating. The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos. So, keep motivating, keep learning and keep loving Pepcoding😊
@prateekbansal2014
@prateekbansal2014 3 жыл бұрын
sir please har video me question ki time or space complexity bhi bta diya karoo ... ya fir description me daal diya karoo
@sagarbhoi7873
@sagarbhoi7873 2 жыл бұрын
nice sir
@ashutoshdixit2806
@ashutoshdixit2806 3 жыл бұрын
listen properly at 14.01 ... it make clear everything
@Pepcoding
@Pepcoding 3 жыл бұрын
Thankyou buddy! If you like our efforts, will you like to write a few words about us here (www.quora.com/How-do-I-start-learning-or-strengthen-my-knowledge-of-data-structures-and-algorithms )
@mukultaneja7243
@mukultaneja7243 4 жыл бұрын
Great explanation sir ! Please tell.... how can we prevent the calls with empty array, because it may take much extra time in higher n and k values.
@Pepcoding
@Pepcoding 4 жыл бұрын
break lgaya hai na, pehle empty set se.
@mukultaneja7243
@mukultaneja7243 4 жыл бұрын
@@Pepcoding oh okay sir got it ! Thankyou so much ❤️
@varsha4260
@varsha4260 4 жыл бұрын
@@Pepcoding but sir ham yaha pe no of set==k check kar rahe hai na,so all those which have only k-1 elements or less than that we are making unecessary calls to it right!Is there any way to prevent making those extra calls?
@ShaniKumar-ql2ow
@ShaniKumar-ql2ow 4 жыл бұрын
you are doing great work sir ! please make videos on dp also.
@Pepcoding
@Pepcoding 4 жыл бұрын
50 questions on DP just got done. Check this www.pepcoding.com/resources/online-java-foundation/dynamic-programming-and-greedy www.pepcoding.com/resources/data-structures-and-algorithms-in-java-levelup/dynamic-programming/
@lovi1999
@lovi1999 4 жыл бұрын
Ekdum mast Sir.
@Pepcoding
@Pepcoding 4 жыл бұрын
It's my pleasure!! keep watching and share as much as you can
@programmertik2046
@programmertik2046 3 жыл бұрын
n=3 1 2 3 k=3 Sir code will fail to handle it wont print anything this test case Correct me if im wrong !!! Baki continue your GOD level teaching sir !!!!
@Pepcoding
@Pepcoding 3 жыл бұрын
Sorry, we won't be able to take your doubts here and assist you here. For better experience visit on nados.pepcoding.com
@srijandasbiswas4864
@srijandasbiswas4864 3 жыл бұрын
Sir ek bahut serious doubt hai ... Ye backtracking kaab jarurat hai ye samajne me thoda problem ho rhi , i mean normal recursion me bhi jab wapas aayega control toh bhi chize toh undo ho jaati hai na Like level1 pe wapas aaya control toh bhi normally level2 ke chize toh undo ho hi jayegi right??
@Pepcoding
@Pepcoding 3 жыл бұрын
Beta, I regret to inform you that, I won't be able to answer/solve the personal doubts of each and every student over here. For clearing your doubts, you can join our community on telegram - t.me/pepcoding.
@ankitgupta-ph4nk
@ankitgupta-ph4nk 2 жыл бұрын
Sir everything is fine here, here we are printing the list and removing, what if i want to return the whole list of k partition subset from this method.
@harshtekriwal131
@harshtekriwal131 4 жыл бұрын
Sir I tried this logic on leetcode but it exceeds time even after many optimizations, is there a better approach for this question?
@tarushiarora6887
@tarushiarora6887 3 жыл бұрын
exactly....can you tell name of this question in Leetcode?
@vibhanshattri
@vibhanshattri 3 жыл бұрын
Do memoisation
@aayushpagare9366
@aayushpagare9366 3 жыл бұрын
PLEASE CAN YOU TELL QUESTION NAME AND NUMBER ?
@hrithikpandey2656
@hrithikpandey2656 3 жыл бұрын
@@aayushpagare9366 698. Partition to K Equal Sum Subsets
@mayur_madhwani03
@mayur_madhwani03 3 жыл бұрын
class Solution { public: bool ans = false; bool isValid(vector& sums){ int n = sums.size(); for(int i = 0 ; i < n - 1 ; i++){ if(sums[i] != sums[i+1])return false; } return true; } void solve(vector& a, int idx, vector& sums, int target){ if(ans == true)return; if(idx == a.size()){ if(isValid(sums))ans = true; return ; } for(int i = 0 ; i < sums.size() ; i++){ if(sums[i]>0 && sums[i] + a[idx]
@nishitadash971
@nishitadash971 3 жыл бұрын
Sir, what if the requirement for partition is contiguous? for example in the set [1,2,3] with k=2.... (13 | 2) cannot be one of the subsets. it can be only ( 12 | 3) or (1 | 23)...? how should I approach this sir?
@punyaslokdutta4362
@punyaslokdutta4362 2 жыл бұрын
Prefix Sum
@AbhijeetSachdev
@AbhijeetSachdev Жыл бұрын
nC(k-1)
@utpalpodder-pk6vq
@utpalpodder-pk6vq 3 жыл бұрын
sir can you please check this input [5,2,5,5,5] 3 its generating some duplicate sequence of outputs... i am facing this issue with leetcode :698. Partition to K Equal Sum Subsets
@utpalpodder-pk6vq
@utpalpodder-pk6vq 3 жыл бұрын
one way I thought i could restrict the processing of duplicate sequence by maintaining a global var which can keep track of the intermediate result ....but its seems not a memory efficient soln....if there any better way I could get rid of it please share it....
@Pepcoding
@Pepcoding 3 жыл бұрын
Gimme some time, I'll check it and beta, I regret to inform you that, I won't be able to answer/solve the personal doubts of each and every student over here. For clearing your doubts, you can join our community on telegram - t.me/pepcoding.
@Yash-uk8ib
@Yash-uk8ib 3 жыл бұрын
@@utpalpodder-pk6vq sir did u get it now?? plzz share with me!! struggling with the same
@hymnish_you
@hymnish_you 3 жыл бұрын
For those who are getting TLE. Sort the array in reverse.
@programmertik2046
@programmertik2046 3 жыл бұрын
how does this help can you explain ??
@vaibhaves
@vaibhaves 4 жыл бұрын
Can you do the egg drop problem? with which floors to drop the eggs from . thanks
@Pepcoding
@Pepcoding 4 жыл бұрын
Sure!
@yogita868
@yogita868 3 жыл бұрын
Sir please upload the solution of a magnet puzzle problem
@011_tanyadixit4
@011_tanyadixit4 2 жыл бұрын
Thank you so much for your insightful explanations sir :) p.s. is this question on leetcode I can't find it
@live_study_with_me
@live_study_with_me 2 жыл бұрын
similar problem is there leetcode 473. Matchsticks to Square
@RahulKumar-od6zk
@RahulKumar-od6zk 3 жыл бұрын
Sir level 2 me aur videos kab aa rhe????
@Pepcoding
@Pepcoding 3 жыл бұрын
Jldi he resume krege beta, most probably by the end of this month.
@RahulKumar-od6zk
@RahulKumar-od6zk 3 жыл бұрын
@@Pepcoding thank you so mush sir, Respect 3000
@sakshamkumarsharma2309
@sakshamkumarsharma2309 4 жыл бұрын
Hi sir should i do your 2500 list of questions of DSA or 500 list of questions of DSA. I am currently in my 2nd year. Please help sir i am really confused
@Pepcoding
@Pepcoding 4 жыл бұрын
500 wali
@vinay8163
@vinay8163 4 жыл бұрын
2500 question ki list dena bhaai ?
@garima6571
@garima6571 2 жыл бұрын
Can u please provide the code in description in c++?
@Pepcoding
@Pepcoding 2 жыл бұрын
check it out on nados.io
@_busybee23
@_busybee23 3 жыл бұрын
GOD
@Pepcoding
@Pepcoding 3 жыл бұрын
Glad to know that you liked the content and thank you for appreciating. The love and respect which I get from you people keep me highly motivated and the same I am able to forward It to you people through my videos. So, keep motivating, keep learning and keep loving Pepcoding😊
@Elon-musk-007
@Elon-musk-007 4 жыл бұрын
How do we know that backtracking is needed or not needed;
@Pepcoding
@Pepcoding 4 жыл бұрын
beta jahan level aur options ki feel aaegi to backtracking lagegi. jahan options dikhne lagein
@Elon-musk-007
@Elon-musk-007 4 жыл бұрын
@@Pepcoding print sequences vaale question mein bhi to 2 options thi vaha backtracking kyon nhi lagayi
@Pepcoding
@Pepcoding 4 жыл бұрын
bilkul lga sakte the. level1 mei print sequence mei lgai hai.
@rahulranjan7567
@rahulranjan7567 3 жыл бұрын
@@Elon-musk-007 JIdhar bhi multiple calls lagti hai and jidhar bhi tumhari input ko reuse karne ka locha hota hai udhar Backtracking laga sakte hai. Idhar se hi DP nikalti hai with slight modifications. Bass yeh samjh lo ki agar problem overlap ho rahi hai toh backtracking lagg sakti hai
@Elon-musk-007
@Elon-musk-007 3 жыл бұрын
@@rahulranjan7567 Thanks bro
@KAMALKAMAL-ig6qc
@KAMALKAMAL-ig6qc 4 жыл бұрын
Sir ek din mein 1-2 questions hi kyu daal rhe ho??
@Pepcoding
@Pepcoding 4 жыл бұрын
jaanke nahi yar. kuch income tax ka kaam aya hua hai. jyada karenge asap. at-least 10-12 per day.
@RajatSingh-dg8ov
@RajatSingh-dg8ov 4 жыл бұрын
Hi sir This code is giving tle on leetcode
@Pepcoding
@Pepcoding 4 жыл бұрын
Okay beta, lemme have a look
@RajatSingh-dg8ov
@RajatSingh-dg8ov 4 жыл бұрын
@@Pepcoding thank you sir, thanks for the prompt reply.
@shubhamaggarwal3823
@shubhamaggarwal3823 4 жыл бұрын
sir , 720p daalo atleast plz.
@Pepcoding
@Pepcoding 4 жыл бұрын
ab theik ho gai hogi.
@prahladrana6391
@prahladrana6391 4 жыл бұрын
sir , ye smjh nhi aaya ki pehli baar jb 1 add hua tb uske liye bhi do calls lagi thi. one where it is added into the existing set and the other where it creates its own set, sir 1 k liye kya hoga matlab nhi ayaa smjh..
@prahladrana6391
@prahladrana6391 4 жыл бұрын
please guide me sir
@Pepcoding
@Pepcoding 4 жыл бұрын
nhi bro. ya to existing non-empty set mei add hona hai ya pehle empty set mei. 1 ko to sare sets empty he mile na.
@prahladrana6391
@prahladrana6391 4 жыл бұрын
​@@Pepcoding​means 1 will never execute that if block.
@ashutoshdixit2806
@ashutoshdixit2806 3 жыл бұрын
****AaAgGg!!!!!!
@Pepcoding
@Pepcoding 3 жыл бұрын
🔥☄️😬🙊
@AmandeepSingh-ot6st
@AmandeepSingh-ot6st 4 жыл бұрын
Bhaya ....c++ mai bhi code likh kar dikhaaya karo.... Ab...kuch bachcho ko java Puri nhi aati ....toh pehle java padhni hogi ...phir code ka flow samaj aayega....phir c++ padhne ka kya hi faayeda... Plzzz...Bhai...c++ mai bhi code likhar dikha diya karo......bahut pareshaani hoti hai...java ka code samajne mai...kyui ye ArrayList Sabhi c++ mai nhi hai...🙄
@Pepcoding
@Pepcoding 4 жыл бұрын
Iske pehle 5 lecture karlo. Basic Java 2-3 din mei aa jaegi. www.pepcoding.com/resources/online-java-foundation
What type of pedestrian are you?😄 #tiktok #elsarca
00:28
Elsa Arca
Рет қаралды 42 МЛН
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 138 МЛН
I was just passing by
00:10
Artem Ivashin
Рет қаралды 18 МЛН
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 39 МЛН
Partition array to K subsets | Problem of the Day : 16/07/2022 | Siddharth Hazra
16:43
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 104 МЛН
Game of Execution - Josephus Problem | Recursion & Backtracking
17:19
What type of pedestrian are you?😄 #tiktok #elsarca
00:28
Elsa Arca
Рет қаралды 42 МЛН