Minimum Number of Taps to Open to Water a Garden | Full Dry Run | ATLASSIAN | Leetcode - 1326

  Рет қаралды 8,402

codestorywithMIK

codestorywithMIK

Күн бұрын

Пікірлер: 110
@codestorywithMIK
@codestorywithMIK Жыл бұрын
(Have been very busy today, apologies I couldn't reply to comments) Hi everyone, upon seeing so many requests for DP video for this problem. The DP video for this problem is being uploaded now. Hope it will help Thank you all ❣
@dhairyachauhan6622
@dhairyachauhan6622 Жыл бұрын
really awesome bhiya u r the best :)
@chaitanya812
@chaitanya812 Жыл бұрын
Thanks bhaiya for solving using 2 different approach
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Glad to hear that it helped you guys. Thank you for watching 😇❤️
@sh1vvyy
@sh1vvyy 8 ай бұрын
after listening to your story, i literally can write the code without any errors and this totally feels like magic i swear, thank you so much!!
@RajanSingh-xr7cf
@RajanSingh-xr7cf 2 ай бұрын
before 2 monts i was not capable for solving the easy level question ------- after watching the 100 video of array playlist ----- get confidence ------------- now accessing the greedy ---------------- BE honestly ..... hardly i will clear the coding round ...... i am in 3rd year (5_sem) ......... BE honsetly ----- i work so hard ----- access almost all the playlist as much as posible__ mera din bhaiya k concept s and night bhiii ____
@souravjoshi2293
@souravjoshi2293 Жыл бұрын
I won't get tired of saying "YOU ARE THE KING OF DSA"
@sauravchandra10
@sauravchandra10 Жыл бұрын
Solved it using greedy by modifying the merge intervals approach. Less efficient than your approach though. Here is the code: class Solution { public: int minTaps(int n, vector& ranges) { vector intervals; for(int i=0;i
@iamnoob7593
@iamnoob7593 3 ай бұрын
Wow i had to see this video 2 times to get the intution regarding currEnd , Thanks
@codestorywithMIK
@codestorywithMIK Жыл бұрын
If anyone is wondering why currEnd is used to increment the tap (tap++), Actually, If at any point we find that the current position cannot be watered from any previous tap, the garden cannot be completely watered, we open a tap (tap++)
@wearevacationuncoverers
@wearevacationuncoverers Жыл бұрын
got it . thanks a lot
@aniketnama8390
@aniketnama8390 3 ай бұрын
we can check it or update it when we are changing maxend is it we ?
@singerpranavmodi
@singerpranavmodi Жыл бұрын
The way you explain specially in Hindi is just brilliant. Keep up the great work. Subscriber earned.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thanks a lot 😊
@kunalwadhai777
@kunalwadhai777 Жыл бұрын
Thank you very much sir for providing such content which helps me to solve leetcode's daily streak problems....and just because of this all your effort sir I earned an August month badge.
@wqffeqf
@wqffeqf 3 ай бұрын
Mast question hai Very nicely explained. After hearing story it got easy. Thank you bro ❤❤❤
@thekindspill
@thekindspill Жыл бұрын
Awesome explanation. 13:20 is the reason why I love this channel. However, I never like greedy problems, they are always very irritating. Please also make DP video for this.
@floatingpoint7629
@floatingpoint7629 Жыл бұрын
very helpful explanation -- thanks for it and dry running the examples.
@yikes3807
@yikes3807 Жыл бұрын
Thanks for your videos sir boht acchese samzate ho
@dayashankarlakhotia4943
@dayashankarlakhotia4943 Жыл бұрын
class solution { Public int min Tap(int n,int []range){ int start =0,end =0,tap=0; while (end
@k.vabhavmishra
@k.vabhavmishra Жыл бұрын
LC 1024 is also similar Problem name is Video Stitching in which it is asked the minimum number of clips needed so that we can cut the clips into segments that cover the entire sporting event
@chaitanya812
@chaitanya812 Жыл бұрын
Thanks for this..... Also asked in Intuit tooo
@dayashankarlakhotia4943
@dayashankarlakhotia4943 Жыл бұрын
Public class solution { Public int min Tap(int n,int []range){ int[]arr=new int [n+1]; Array. fill (arr,0); for(int i=0;i
@ganeshmula4508
@ganeshmula4508 Жыл бұрын
Thank you sir💥💥💫🙏🙏🙏
@shivaggarwal4073
@shivaggarwal4073 Жыл бұрын
at 3:21, we cannot take index = 5 because [4,5) will be unwatered and only [5,5] range will be watered, we can instead take index 4 and our whole range of garden will be watered.
@YashSinghal
@YashSinghal Жыл бұрын
nice solution and explained amazingly
@dhairyachauhan6622
@dhairyachauhan6622 Жыл бұрын
Bhiya if possible can u make a video for the same question using dp. It will be really helpfull also you can add that to the dp questions and concepts playlist 😅🔥
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Definitely 😇❤️🙏
@codestorywithMIK
@codestorywithMIK Жыл бұрын
See my Pinned comment ☺❣
@mohithadiyal6083
@mohithadiyal6083 Жыл бұрын
The best explanation
@adilkhatri7475
@adilkhatri7475 Жыл бұрын
3 times dekha tab samja but samj gaya.
@anuppatankar4294
@anuppatankar4294 Жыл бұрын
Great Video 🔥
@rajkrishanmahajan2373
@rajkrishanmahajan2373 Жыл бұрын
for who those want to solve similar question search no (45)Jump Game II && (1024) Video Stitching
@AmarjeetKumar-to9ub
@AmarjeetKumar-to9ub Жыл бұрын
Thank You :)
@vineethkumar8094
@vineethkumar8094 9 ай бұрын
It would be great if you could post such informative videos in English as in IT industry we are going to communicate in English..Looks like your videos will be useful only for Hindi knowing audience...Pls take it as a humble suggestion. Thanks a lot for the video
@TheProblemSolvers38
@TheProblemSolvers38 Жыл бұрын
You didn't tell the reason why we are increasing the taps count when i > currEnd. This is same like memorizing the code.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Hi there , Apologies if you felt so. I ensure that my videos are never memorised. However if you felt so in this video, i will try to improve it. Let me try it here. Whenever you are at any index i, you know two things : 1) What is the maxend on right side which is watered by any past tap. If you have already crossed it (i.e. i > maxEnd) It means that even after maintaining the maxEnd till now, i reached out of bound of maxEnd which indicates that it’s not possible to water the garden. 2) you have not crossed the maxEnd but you have crossed the limit of your last seen tap. For example : when you are at index 0, you set maxEnd to something but you never incremented the tap count because if the beginning your current limit you assumed was 0 and now as soon as you moved to index 1 and you realised that you have crossed your currlimit that was index 0, you should have opened the tap. So we do tap++ in that case. I really appreciate your feedback but i want to ensure that I never try to make any video on concepts which people have to memorise because that will defeat the purpose of my teaching. Thank you so much ❤️❤️❤️ Also kindly check out my DP video for this same problem.
@TheProblemSolvers38
@TheProblemSolvers38 Жыл бұрын
@@codestorywithMIK Hey, really loved your positive spirit.....Just saw your Dp solution and I understood the dp solution in an easy way. Greedy solution is a bit complicated.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
@EnglishTracks Totally agree brother. Thank you for your feedback and response 😇❤️🙏
@YashSinghal
@YashSinghal Жыл бұрын
was not able to memoize my recursive solution 😅 class Solution { public: int solve(int n, vector& ranges, int idx, vector watered){ if(idx==n){ for(int i = 0; i
@YashSinghal
@YashSinghal Жыл бұрын
the greedy approach is almost impossible to think if not already seen before
@codestorywithMIK
@codestorywithMIK Жыл бұрын
See my Pinned comment ☺❣
@dayashankarlakhotia4943
@dayashankarlakhotia4943 Жыл бұрын
dp solution. class solution { Public int minTap(int n,int[]range){ final int INF=(int)1e9; int[]dp=new int [n+1[; Array. fill (dp,INF); dp[0]=0; for(int i=0;i
@053_tanweer7
@053_tanweer7 Жыл бұрын
Please write memorize version
@dhairyachauhan6622
@dhairyachauhan6622 Жыл бұрын
SOLUTION USING DP class Solution { public: int dp[(int)1e4+7]; int solve(vector&startEnd,int idx){ int n = startEnd.size(); if(startEnd[idx].second >= n-1){ return 1; } int ans = 1e9; if(dp[idx]!= -1){ return dp[idx]; } for(int j = idx+1;j startEnd[idx].second){ break; // cant go ahead } int val = 1 + solve(startEnd,j); ans = min(ans,val); } return dp[idx] = ans; } int minTaps(int n, vector& ranges) { vectorstartEnd; // step 1 make the table of ranges for(int i = 0;i
@codestorywithMIK
@codestorywithMIK Жыл бұрын
See my Pinned comment ☺❣
@nikeshsingh2081
@nikeshsingh2081 7 ай бұрын
Add similar type questions for hw
@chetnamittal9537
@chetnamittal9537 Жыл бұрын
Not quite understood the use of current end
@suvamroy6205
@suvamroy6205 6 ай бұрын
I still dont get whats the need for currentEnd?
@chaitanya812
@chaitanya812 Жыл бұрын
can you upload the dp solution too as when i saw it dp was my initial thought
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Same 😇
@codestorywithMIK
@codestorywithMIK Жыл бұрын
See my Pinned comment ☺❣
@saquibabbas1709
@saquibabbas1709 Жыл бұрын
Mik Sir can you explain #DynamicProgramming Approach
@codestorywithMIK
@codestorywithMIK Жыл бұрын
See my Pinned comment ☺❣
@unknown47896
@unknown47896 4 ай бұрын
i really hate greedy problems
@sarthakyadav9950
@sarthakyadav9950 Жыл бұрын
Bhai ye greedy problems ka koi tod batao intuition build karne ka boht difficult jata hai
@darshandesale
@darshandesale Жыл бұрын
apne kya steps follow kiye the batao na me karne ke liye tayar hu
@phoddaal7130
@phoddaal7130 Жыл бұрын
Sir aapke jump game 2 wale solution mein if( i == curEnd), wali condition use hui hia and isme aapne if( i > curEnd), iska kya reason hai, ye difference kyon aya hai . Is it because in this question tap ka effect peeche wali side bhi and jump game wale question mein sirf effect of jump forward direction mein hi hai. So, we can go ahead and check if there is need to on the tap later. But in jumping, we have to jump prior coz i cannot move forward if i don't increase jump so i have to increase the point i cannot move index
@ishwarkoki1119
@ishwarkoki1119 Жыл бұрын
ye maine dp se solve kiya, greedy mereko nhi chamka
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Actually Greedy problems are always a pain. I hope when I share DP solution that will be more helping ❤️🙏
@053_tanweer7
@053_tanweer7 Жыл бұрын
Greedy se jyada ab dp chamkta hai
@codestorywithMIK
@codestorywithMIK Жыл бұрын
See my Pinned comment ☺❣
@top_g755
@top_g755 Жыл бұрын
Sir maine aapke unique binary search tree wale video par ek question puch h please reply kariye
@factsmadeiteasy9943
@factsmadeiteasy9943 Жыл бұрын
bhaiya are you currently working in some comapny?
@tutuimam3381
@tutuimam3381 Жыл бұрын
❤❤❤
@sachinmohanty4577
@sachinmohanty4577 Жыл бұрын
Please MIK post DP solution also today itself if possible 😢
@codestorywithMIK
@codestorywithMIK Жыл бұрын
See my Pinned comment ☺❣
@MrUnknown-g4u
@MrUnknown-g4u Жыл бұрын
I can't understand why it can't water when n = 3 and arr ={1,0,0,1}
@darshandesale
@darshandesale Жыл бұрын
bhaiya apse samz leta hu par khudse nahi solve ho pate he kya karu please batao na bohot pareshani me hu
@audumbarchinchkar5262
@audumbarchinchkar5262 Жыл бұрын
if we set currEnd =-1 before starting and change the order of last for loop will this work?
@TheProblemSolvers38
@TheProblemSolvers38 Жыл бұрын
Try
@audumbarchinchkar5262
@audumbarchinchkar5262 Жыл бұрын
@@TheProblemSolvers38 I did dry but it does work for some cases but not for all and I am unable to decipher why?
@yashgarg3027
@yashgarg3027 Жыл бұрын
bhaiya jump game 2 i have solved using dp please bhaiya by today only upload dp solution of this as well
@amitguptapc
@amitguptapc Жыл бұрын
not able to understand why currentEnd is used😢
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Actually Greedy problems are always a pain to understand most of the times. I hope when I share DP solution that will be more helping ❤️🙏
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Actually, If at any point we find that the current position cannot be watered from any previous tap, the garden cannot be completely watered, we open a tap (tap++)
@amitguptapc
@amitguptapc Жыл бұрын
@@codestorywithMIK Thanks a lot bro. I really enjoy all your videos. Thank u for addressing my query. Wishing ur channel great success.
@codestorywithMIK
@codestorywithMIK Жыл бұрын
@amitguptapc means a lot ❤️😇
@thekindspill
@thekindspill Жыл бұрын
@@codestorywithMIK Thanks lot. I got it.
@raganaroak182
@raganaroak182 Жыл бұрын
🙏🙏🙏
@Rajat_maurya
@Rajat_maurya Жыл бұрын
Jump game II toh DP and memo se ban gaya
@codestorywithMIK
@codestorywithMIK Жыл бұрын
See my Pinned comment ☺❣
@dayashankarlakhotia4943
@dayashankarlakhotia4943 Жыл бұрын
good explanation dp solution ka Tc0(n*n); ha please tell me
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Yes DP is quadratic
@codestorywithMIK
@codestorywithMIK Жыл бұрын
See my Pinned comment ☺❣
@3011hi
@3011hi Жыл бұрын
@codestorywithMIK sir after ur last guidance video sir.. I started arrays ,2d arrays and vectors and completed it.. Now I wanna do leetcode questions as u told in video but not understanding which to do.. If possible in ur next video can u pls give list of pure topic wise questions sir ( without mixed concept).. It will be very helpful.. Can we expect the video on this sunday
@xiaoshen194
@xiaoshen194 Жыл бұрын
Yr 😭😭. I failed firse. Main kabse DP try kr rha tha (choose-not choose). Pta hi nhi chalta greedy h Ki dp
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Trust me you didn’t fail. There is a DP solution as well. I will be sharing DP video on this soon and will also explain why “choose-not choose” is not suitable for this problem
@xiaoshen194
@xiaoshen194 Жыл бұрын
@@codestorywithMIK thnk U😃🙏
@Ashwani64323
@Ashwani64323 Жыл бұрын
​@@codestorywithMIKrespected sir kya aap wo video aaj hi upload krenge ...ho ske to aaj hi kr dijiyega...Maine bhi dp se try kia tha
@codestorywithMIK
@codestorywithMIK Жыл бұрын
See my Pinned comment ☺❣
@39_jatinjain4
@39_jatinjain4 Жыл бұрын
today's question is little bit confusing
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Actually Greedy problems are always a pain. I hope when I share DP solution that will be more helping ❤️🙏
@39_jatinjain4
@39_jatinjain4 Жыл бұрын
@@codestorywithMIK yes now it's easy but when I will try to do this after some time then definitely it creates problem
@codestorywithMIK
@codestorywithMIK Жыл бұрын
See my Pinned comment ☺❣
@RahulGuptaa29
@RahulGuptaa29 Жыл бұрын
DP is technique, Greedy is art
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Indeed See my pinned comment 😇
@aravindkumarn1776
@aravindkumarn1776 Жыл бұрын
Tell me whats the use of creating education content in hindi?Did any tier1 and tier2 ask you explain the solution in hindi in any interview? What about people from south or who dont know hindi and having keen on solving problem in leetcode using your channel?
@rahulmaurya6451
@rahulmaurya6451 Жыл бұрын
bhai... yeh koi English Education Lecture ni hai ,, Yha concepts milta hai and all of us here only for the valuable concepts and Only MIK can explain these concepts perfectly in a very Layman terms ... Even someone who don't know coding can easily learn these concepts from MIK. For those who don't know their own mother tongue they should try to learn Hindi first not the Foreign One.
@thekindspill
@thekindspill Жыл бұрын
@@rahulmaurya6451 Totally agree with you bhai. Also @aravindkumarn1776, I would suggest you to use any online translator. But, I don't agree with your point "whats the use of creating education content in hindi" It's totally upto the guy how he wants to create his content. I understand that making videos in English might make it reachable to many more But the point is for people who don't understand English well, or those who like things in Hindi or friendly way, this content is gold. Please don't mind if any of my words hurt anyone, but I am speaking as per what I have seen in my college. People have gone crazy for this channel and literally everyone watches his channel in my college.
@wearevacationuncoverers
@wearevacationuncoverers Жыл бұрын
@@rahulmaurya6451 💯
@wearevacationuncoverers
@wearevacationuncoverers Жыл бұрын
Hey @aravindkumarn1776, I am also from South. Fortunately my flatmate understands Hindi and he explains it to me where I don't understand some Hindi words. But I think you can use online AI tools like dubverse . They automatically add English subtitles to the video. Hope that helps bro
@aravindkumarn1776
@aravindkumarn1776 Жыл бұрын
@@wearevacationuncoverers Thanks brother for suggesting new tool. tell me, In case if no one from your circle dont know hindi, then definitely you can feel the pain
Sliding Window Technique - Algorithmic Mental Models
36:45
Ryan Schachte
Рет қаралды 363 М.
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 9 МЛН
Players push long pins through a cardboard box attempting to pop the balloon!
00:31
МЕНЯ УКУСИЛ ПАУК #shorts
00:23
Паша Осадчий
Рет қаралды 5 МЛН
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 4,7 МЛН
Extremal Combinatorics Lecture 34: Bregman's Theorem
50:36
Jonathan Noel
Рет қаралды 1
Minimum Window Substring | Google | Leetcode 76
38:06
codestorywithMIK
Рет қаралды 21 М.
NVIDIA’s New AI: Stunning Voice Generator!
6:21
Two Minute Papers
Рет қаралды 78 М.
⚡️NEWS | RUBLE COLLAPSE | STRIKE ON CRIMEA | PUTIN IN KAZAKHSTAN
10:34
Ходорковский LIVE
Рет қаралды 196 М.
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 9 МЛН