HackerRank - Equal | Full Solution with Simplified Examples and Visuals | Study Algorithms

  Рет қаралды 14,364

Nikhil Lohia

Nikhil Lohia

Күн бұрын

Пікірлер: 48
@srinjaykapri7
@srinjaykapri7 3 жыл бұрын
voice(not so quick not so slow moderate)& explanation are on 🔥
@sudarshanmaskare3328
@sudarshanmaskare3328 Жыл бұрын
Nice solution, we can have only three possibilites[ (min-0),(min-1),(min-2)],,,,,(min-5) will lead to recurrence.... Why? because in question we are given [1,2,5]... This works for me-> int equal(vector arr) { vector possibilities(3); // Start with the minimum element int minimum = *min_element(arr.begin(),arr.end()); for (int i = 0; i < 3; i++) { for (int k : arr) { int diff = k - minimum; int stepsRequired = diff / 5 + (diff % 5) / 2 + ((diff % 5) % 2) / 1; possibilities[i] += stepsRequired; } minimum--; } // Return the minimum number out of all the possibilities return *min_element(possibilities.begin(),possibilities.end()); }
@artistic__08
@artistic__08 Жыл бұрын
My first thought was solving this through BFS
@doingsneakypeakylike
@doingsneakypeakylike 3 жыл бұрын
Thanks brother! Finally I understood it. The visuals and explanation were really good.
@rajeshpaithari7320
@rajeshpaithari7320 8 ай бұрын
Heya, I'm still confused about min to min-4.
@praveenmani5672
@praveenmani5672 8 ай бұрын
Bro, Thanks a lot, finally understood the solution
@PIYUSH61004
@PIYUSH61004 2 жыл бұрын
Please explain more about the optimal solution being present in [min, min-4] range
@nikoo28
@nikoo28 2 жыл бұрын
The range comes from the fact that you can either give 1, 2 or 5 chocolates. That's why you have to check all the possibilities in that range. We do not go past "min-4" because that will take 5 operations which is same as a single operation of giving 5 chocolates at once. Hope that helps.
@PIYUSH61004
@PIYUSH61004 2 жыл бұрын
@@nikoo28 Finally I understood.. Thanks a lot, brother!
@kumarisuruchisuman8919
@kumarisuruchisuman8919 3 жыл бұрын
what a explanation man
@vtmcedxc2573
@vtmcedxc2573 3 жыл бұрын
your explanation was great, it really helped me
@urbancoder96
@urbancoder96 2 жыл бұрын
That is genius!
@sculptandstyle_
@sculptandstyle_ 2 жыл бұрын
i don't understand why only till min-4 is considered
@ajaysubramaniam4453
@ajaysubramaniam4453 10 ай бұрын
well explained.
@tanishqmahendrasaini3764
@tanishqmahendrasaini3764 3 жыл бұрын
Very nice bro 😃 Well explained & animation made it so easy Thank You!!
@lahiruweliwitiya1
@lahiruweliwitiya1 3 жыл бұрын
Thank you for this explanation!
@jorgegonzaloalfaro5378
@jorgegonzaloalfaro5378 3 жыл бұрын
wow this was really good thank you!!!
@kartika9415
@kartika9415 3 жыл бұрын
Great Work !!!!
@markohy9samy565
@markohy9samy565 Жыл бұрын
great explaination Thx alot !
@vijaykumarsingh5862
@vijaykumarsingh5862 3 жыл бұрын
how you come to know that min will go till min-4??
@nikoo28
@nikoo28 3 жыл бұрын
That is because she can give a maximum of 5 chocolates. If she was able to give 8 chocolates, then you would have to check till 7.
@aakrandan
@aakrandan 3 жыл бұрын
@@nikoo28 This is a vital information, should have mentioned in the description.
@nikoo28
@nikoo28 3 жыл бұрын
@@aakrandan This information is mentioned in the problem description. :)
@manojkalyan94
@manojkalyan94 Жыл бұрын
@@nikoo28 No where mentioned max of 5 chocolates can be distributed in pblm statement I have checked it
@radhakalyaninakka5877
@radhakalyaninakka5877 2 жыл бұрын
very interesting explanation
@rohanjain4238
@rohanjain4238 2 жыл бұрын
very detailed explanations
@ayabc4320
@ayabc4320 3 жыл бұрын
Great video :) 😊
@siddhigolatkar8558
@siddhigolatkar8558 3 жыл бұрын
Thank you
@alakmarshafin9065
@alakmarshafin9065 3 жыл бұрын
Nicely explained
@aakashkatiyar5005
@aakashkatiyar5005 3 жыл бұрын
Very helpful!!
@shwetaravi2696
@shwetaravi2696 3 жыл бұрын
bruh i have a doubt what if min=2,then will the still continue till it calculates min-4
@nikoo28
@nikoo28 3 жыл бұрын
yes…you need to calculate every possible min. Otherwise how will you know that min =2?
@doremifasolatee6258
@doremifasolatee6258 8 ай бұрын
14:05 can someone please explain to me how is (minimum - 5) the same scenario??
@nikoo28
@nikoo28 8 ай бұрын
it is like dividing in groups of 5. the scenario will be same if it is 30 or 25 or 35
@hoddybhaba6704
@hoddybhaba6704 2 ай бұрын
I had the same doubt on watching this video…
@BestOption19
@BestOption19 3 жыл бұрын
when we reach min-5 then how it will be same scenario ??(14:02)
@nikoo28
@nikoo28 3 жыл бұрын
If you reach ‘min-5’, then you will reach the same scenario you started with. Try to do a dry run and take away 5 chocolates, you will find yourself in a recurrence :)
@uttamkumarreddygaggenapall2504
@uttamkumarreddygaggenapall2504 3 жыл бұрын
according to algorith ans to 1 5 5 is 4 but the true ans is 3
@nikoo28
@nikoo28 3 жыл бұрын
Can you describe the 3 steps to make the distribution equal?
@uttamkumarreddygaggenapall2504
@uttamkumarreddygaggenapall2504 3 жыл бұрын
Adding 5 6 10 5 Adding 5 11 10 10 Adding 1 11 11 11
@aakrandan
@aakrandan 3 жыл бұрын
@@nikoo28 take 1 from first ==> 1 operation take 5 from second ==> 2 operation take 5 from third ==> 3operation Not sure if 0,0,0 can be the answer or not.
@nikoo28
@nikoo28 3 жыл бұрын
​@@aakrandan 3 is the correct answer. If you try to run the code I have provided, it will give you the answer 3. I think from my explanation you missed the part to check for a range of "min" to "min - 4"
@yashgupta6797
@yashgupta6797 2 жыл бұрын
consider min from [min,min-4]
@hoddybhaba6704
@hoddybhaba6704 2 ай бұрын
Don’t understand the Min to min -4 logic
@vikasgowdalv770
@vikasgowdalv770 3 жыл бұрын
Worst voice ever heard :)
@nikoo28
@nikoo28 3 жыл бұрын
Thanks for your feedback, in an effort to constantly improve please let me know what kind of issues did you face. I will try to improve it in my next video.
@sheikhyawar2628
@sheikhyawar2628 3 жыл бұрын
You have nothing to do with his voice, he is doing a great job let him continue you just focus on your voice.we don't come here to judge his voice but to understand his problem solving technique.
@vikasgowdalv770
@vikasgowdalv770 3 жыл бұрын
@@sheikhyawar2628 BTW brother, I never commented on his problem solving skills ik he's a good problem solver And moreover I'll comment what I feel @Study Algorithms pleas do use autotuned voice it's really difficult to listen Hope you understand:)
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 60 МЛН
What type of pedestrian are you?😄 #tiktok #elsarca
00:28
Elsa Arca
Рет қаралды 35 МЛН
HackerRank Dynamic Programming 2 - Count the Array (35 pts)
12:21
How to STUDY so FAST it feels like CHEATING
8:03
The Angry Explainer
Рет қаралды 1,8 МЛН
A Deep Understanding of Dynamic Programming [Intro / Overview]
29:03
Big-O Notation - For Coding Interviews
20:38
NeetCode
Рет қаралды 518 М.
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59