Rotten Oranges (BFS) | C++ & Java Code |G-10. Rotten Oranges

  Рет қаралды 60,589

take U forward

take U forward

Күн бұрын

Пікірлер: 125
@takeUforward
@takeUforward Жыл бұрын
Please watch our new video on the same topic: kzbin.info/www/bejne/r5eWoIieoNukd5I
@ahishnar1568
@ahishnar1568 3 жыл бұрын
About to practice this question and notification appeared. What a timing 😅 Consistency 🔥🔥🔥 Thanks for the video Bhaiya.
@gauravgautam5963
@gauravgautam5963 2 жыл бұрын
literally . I have to say you explain it very well. As i have tried from many video to understand this question but your way of explaining is on another level
@sumitkulkarni3950
@sumitkulkarni3950 3 жыл бұрын
geeksforgeeks has very lengthy code for this question. You have simplified it. Thanks
@takeUforward
@takeUforward 3 жыл бұрын
Please like, share and subscribe to these kind of content also. Do let me know in comment section if you have understood or not :) New and better edition: kzbin.info/www/bejne/r5eWoIieoNukd5I
@AmanKumarSinhaOfficial
@AmanKumarSinhaOfficial 3 жыл бұрын
Please Bhaiya... Make a video for BCA Student who wants to get job just after completing BCA - Off campus roadmap...
@takeUforward
@takeUforward 3 жыл бұрын
@@AmanKumarSinhaOfficial areh mene wo chiz kia hi nai, toh video kese banaye bhai.
@AmanKumarSinhaOfficial
@AmanKumarSinhaOfficial 3 жыл бұрын
@@takeUforward .......
@ratnadeepbhattacharya3237
@ratnadeepbhattacharya3237 3 жыл бұрын
Bhaiya trees ka series kab ayega like approximate time kuch? BTW nice explanation.....keep up the gd work 👍
@manaswitadatta
@manaswitadatta 3 жыл бұрын
Hi, can you pls provide the link for the SDE theory topics sheet. I remember seeing it but can't find the link. Pls.
@laraibanwar1618
@laraibanwar1618 3 жыл бұрын
I really appreciate your work what you are doing for the students of college level I am already working in a company but I do codeforces generally One algorithm on which I had the most difficulty was line sweep algorithms Can u make videos on that topic for the students It would be great U can find the sources from hackereath and topcoder as well or from cp algorithms Thanks
@teetanrobotics5363
@teetanrobotics5363 2 жыл бұрын
Thank you striver for your amazing playlists. Could you please make a playlist on "STRINGS" as well ?
@RonitChattopadhyay
@RonitChattopadhyay 3 жыл бұрын
Hello Striver Bhai.. Thanks for your hard work. Your videos are followed not just by students, but experienced software engineers also like me.
@tanmaysinghal8370
@tanmaysinghal8370 2 жыл бұрын
nice way to check the count of how many rotten oranges are there ... i just used a double for loop to check if there is any 1 left in the matrix... couldn't think of your way
@dhruvsharma7964
@dhruvsharma7964 3 жыл бұрын
Great video, just need a clarification. You have told in live class that we should never change the given value in input, but here you have modified the grid.
@takeUforward
@takeUforward 3 жыл бұрын
Yeah if I was giving interview, I would have asked the interviewer, here i was solving a lc problem, so did it like this.. General order: Ask the interviewer, generally they will ask you not to modify it :)
@dhruvsharma7964
@dhruvsharma7964 3 жыл бұрын
@@takeUforward In that case should I make a copy of the grid and then modify that or is there some better way?
@HarivanshKripaVlogs
@HarivanshKripaVlogs 3 жыл бұрын
That happiness when your video appears at the top..!!! Aab to ache se samajh aa jayega
@bhaveshkumar6842
@bhaveshkumar6842 2 жыл бұрын
I am the biggest fan of the way you teach and I also get to learn how to write neat code.
@alternative8234
@alternative8234 3 жыл бұрын
Brother you're doing a beautiful work. Hope to thank you in person someday.
@akshatsemwal_14
@akshatsemwal_14 3 жыл бұрын
BHAIYA PLEASE MAKE A VIDEO FOR A FRESHER 1ST YEAR IN TIER 3 COLLEGE COMPUTER SCIENCE BRANCH. 1. ROADMAP STARTING OF COLLEGE TILL END OF PLACEMENT A PROPER DETAILED ONE WITH SOURCES OF SITE OR APP TO PURSUE CODING COURSES TO GET PLACED IN TOP MNC's 2. ALSO, COMPANIES AND TIME AT WHICH ONE SHOULD APPLY FOR PAID/NON-PAID INTERNSHIPS. 3. ALSO PROPER TIME ONE SHOULD INVEST IN HIS CO-CURRICULAR ACTIVITIES + CODING + COLLEGE STUDY. 4 . AND EVERYTHING ABOUT GATE EXAM WHETHER ONE SHOULD THINK ABOUT IT AND HOW TO MANAGE BOTH ROADMAPS AS WELL AS PREPARATION AND ALSO WHEN TO PREPARING FOR GATE. 5. STUDY MATERIAL TO FOLLOW IN ORDER TO MAINTAIN COLLEGE GRADES. PLEASE BHAIYA DO MAKE A VIDEO!!!
@karanudayandas1608
@karanudayandas1608 3 жыл бұрын
Time and Space Complexity :- 25:06
@baranikumar6220
@baranikumar6220 3 жыл бұрын
Clear explanation . You made it quite easy to understand this problem. Thank a lot !
@dheerajgoyal6471
@dheerajgoyal6471 3 жыл бұрын
in the if statement of c++ code where you are checking the !=1, there can be a value which is equal to 0 and in that case why we have to mark that as 2(rotton) the if will also contain(&&grid[nx][ny[!=0)?
@takeUforward
@takeUforward 3 жыл бұрын
Only if its 1 we mark else we don’t
@tulika2863
@tulika2863 3 жыл бұрын
How to think whether BFS or DFS should be applied on the grid? I always get stuck in this. Please reply.
@takeUforward
@takeUforward 3 жыл бұрын
Its a standard problem. Generally when there is a pattern of movement. Like here its always 4 directions. Both bfs and dfs can be applied.. Dfs is preferred when we need some backtracking stuff. Here we did not, so bfs dfs both work fine
@vighneshhegde4580
@vighneshhegde4580 3 жыл бұрын
Like, whenever u are seeing that it is radially increasing, then there is a strong chance that BFS will be applicable over there
@tulika2863
@tulika2863 3 жыл бұрын
@@takeUforward Thank you 😇
@tulika2863
@tulika2863 3 жыл бұрын
@@vighneshhegde4580 Thank you 😇
@samgodse9771
@samgodse9771 3 жыл бұрын
You are Great Striver ! Keep it Up | No one Provides This Level of Contents Even Paid Courses can't match with Your KZbin Free Contents. Thank you
@lakshminagaraju206
@lakshminagaraju206 3 жыл бұрын
Thank you for the great explanation. You are truely inspiration
@bhavyanayyer3391
@bhavyanayyer3391 3 жыл бұрын
Sir pls make video on distinct subsequences (dp) and regular expression match pls🙏
@nishchaygupta9988
@nishchaygupta9988 2 жыл бұрын
Hey, the overall explanation is great. But I have one doubt in the S.C. It should be O(n*n) + O(2n) for vector of vector and queue.
@Lovekush-kx5kz
@Lovekush-kx5kz 2 жыл бұрын
Ya it can be but overall it becomes O(n*n)
@nishchaygupta9988
@nishchaygupta9988 2 жыл бұрын
@@Lovekush-kx5kz alright
@kabirbanerjee6159
@kabirbanerjee6159 3 жыл бұрын
Thanks bhaiya for explaining the problem in such an amazing way . I am currently in first year and I have solved most of the questions in the SDE sheet myself . Bhaiya I want to ask a question that from second year should I learn web development or android development and focus on dev related things or should I continue with problem solving . Bhaiya please reply.
@abhinavshukla6418
@abhinavshukla6418 3 жыл бұрын
i am a student of DTU ,is CP necessary for beiing placed in a gud company ,isnt leetcodde nd gfg sufficient??
@bharatpipare7655
@bharatpipare7655 3 жыл бұрын
Bhaiyya Will you please explain us the Time complexity n It's notations in a simple way, I am facing difficulty while understanding.
@aryanyadav3926
@aryanyadav3926 2 жыл бұрын
Thanks for the brilliant explanation!
@itianshub5650
@itianshub5650 3 жыл бұрын
Great Explanation Bhaiya. Thnk u...
@unnatimishra
@unnatimishra 3 жыл бұрын
I badly needed this video, Thank Youu for making 🤩
@aarushi6601
@aarushi6601 3 жыл бұрын
Will using dfs make the problem complicated? Is that why it is not used
@jaiminsolanki5478
@jaiminsolanki5478 3 жыл бұрын
We can't thank you enough Raj Bhaiya!
@adityatiwari1022
@adityatiwari1022 2 жыл бұрын
can this problem be solved using recursion?
@sukritakhauri65
@sukritakhauri65 2 жыл бұрын
Loved the explanation
@dollyyadav3251
@dollyyadav3251 2 жыл бұрын
y u did'nt maintain a visited grid so that while making call in 4 directions we don't need to recompute for the previously visited cell of the grid.
@rishabhkumar8115
@rishabhkumar8115 3 жыл бұрын
can someone please explain me why we are updating our day only when the q size is not 0, . it becomes zero in last iteration so our day will become less then 1??
@jatilyadav4000
@jatilyadav4000 2 жыл бұрын
amazing explaination
@himeshgupta6478
@himeshgupta6478 3 жыл бұрын
I am from non cse background can you please guide me. What kind of questions are asked from operating systems for placement interviews??
@shrimpo6416
@shrimpo6416 3 жыл бұрын
GREAT explanation and very clean, elegant code!
@kundanranjan
@kundanranjan 3 жыл бұрын
How does the algorithm make sure that the time taken is minimum ? Or I think the time is fixed and there can not be any minimum or maximum time. Correct me if I am wrong.
@SantoshSHARMA-vb1kv
@SantoshSHARMA-vb1kv 2 жыл бұрын
hey striver!! can u plz tell why this code is creating problem as it is error ....if u can guide it'll be really very helpful
@vikashkumar7762
@vikashkumar7762 2 жыл бұрын
Bahut shi explain kia h BOSS
@pallavibhasme13
@pallavibhasme13 3 жыл бұрын
Hi ...can plz make a video on, how to make project... I'm 3 yr student but don't know how to make even staring of projects , and which topic is to select... plzz
@yeswanthh5068
@yeswanthh5068 2 жыл бұрын
Understood sir
@sushantkhattar2598
@sushantkhattar2598 3 жыл бұрын
Very well explained solution.Thanks 👍
@ytsh5752
@ytsh5752 2 жыл бұрын
Thanks sir
@stutij7922
@stutij7922 3 жыл бұрын
What will be the time complexity if I solve using DFS I will have to call DFS multiple times to ensure that final time is minimum. Could you plz explain time complexity in dfs
@ore_wa_king
@ore_wa_king 3 жыл бұрын
Thank you Sir
@nitinshukla4960
@nitinshukla4960 2 жыл бұрын
Thanks Striver Buddy
@codeguy21
@codeguy21 3 жыл бұрын
consistency level 100...
@_-6912
@_-6912 3 жыл бұрын
I understood the solution!
@jatinagarwal1605
@jatinagarwal1605 2 жыл бұрын
What if grid does contains more than one rotten oranges then code doesn't seems to work since count_fresh!=cnt in that case..correct me if I'm wrong
@lifegood6401
@lifegood6401 3 жыл бұрын
Superb Explanation as always..
@bhaveshkumar6842
@bhaveshkumar6842 2 жыл бұрын
Thank you, Striver!!!!
@ayeshasumaiya8280
@ayeshasumaiya8280 2 жыл бұрын
Best Explaination💯
@manasdeora4601
@manasdeora4601 2 жыл бұрын
Amazing explanation man!
@jatilyadav4000
@jatilyadav4000 2 жыл бұрын
thank you soo much ...highly appreciated
@freshcontent3729
@freshcontent3729 3 жыл бұрын
bro upload more videos like reverse the string with all approaches
@chandangunaga6810
@chandangunaga6810 3 жыл бұрын
Doubt!! Doubt!! Sir please do check my comment... I am in my end of 3rd year and i am from a tier 3 college... I have started my DSA journey... I m refering your SDE sheet I have doubt in my way of learning it.. I am seeing your solution tutorial , understanding the problem, and write the code by myself after watching the complete video... Is this method is right?or Any suggestion frkm you sir so that i can get a placement in PBC?
@takeUforward
@takeUforward 3 жыл бұрын
Way to go
@KshitijJain
@KshitijJain 2 жыл бұрын
Hey, Can you please cover Trapping Rain Water problem please.
@takeUforward
@takeUforward 2 жыл бұрын
I did
@KshitijJain
@KshitijJain 2 жыл бұрын
@@takeUforward it should be also in stack playlist?
@swetajha2265
@swetajha2265 3 жыл бұрын
good explanation!!
@pedadagopal3062
@pedadagopal3062 3 жыл бұрын
brother,if possible try to also make videos of problems in cp sheet and cr sheet.Also some hackearth links are not working in cp sheet it is showing 404 not found.
@abhishekagarwal3843
@abhishekagarwal3843 3 жыл бұрын
I want the next video on Rabin karp and z algorithm please!
@angshuman_roy
@angshuman_roy 3 жыл бұрын
​I m in my last year but still struggling with basic dsa ,what should I do considering I do have now a time constrain ?
@abhinavshukla6418
@abhinavshukla6418 3 жыл бұрын
bulk recruitment
@rajatverma7936
@rajatverma7936 3 жыл бұрын
its Just Wonderful
@AmanKumarSinhaOfficial
@AmanKumarSinhaOfficial 3 жыл бұрын
Please Bhaiya... Make a video for BCA Student who wants to get job just after completing BCA - Off campus roadmap...
@AdityaPrakashSinha
@AdityaPrakashSinha 3 жыл бұрын
👍👍👍
@Ryan-mr9pn
@Ryan-mr9pn 3 жыл бұрын
Why the dfs approach wasn't chosen here and instead we went with bfs
@tusharrustagi5729
@tusharrustagi5729 2 жыл бұрын
understood
@freshcontent3729
@freshcontent3729 3 жыл бұрын
Conintute the sheet bro placements are startinig! increase upload frequnecy and thanks again
@sankalpmehadia9252
@sankalpmehadia9252 3 жыл бұрын
An alternate solution using O(1) space: class Solution { //Function to find minimum time required to rot all oranges. public boolean check(int[][] grid) { //checks if there is some fresh orange and mekes all -1 to 2 so we don't need extra space int n=grid.length; int m=grid[0].length; boolean b=true; for(int i=0;i
@takeUforward
@takeUforward 3 жыл бұрын
this isn't o(1) space, when you modifying the given data, we consider that into space complexity as well.. Also interviewers don't like such solutions where you modify the give grid..
@sankalpmehadia9252
@sankalpmehadia9252 3 жыл бұрын
@@takeUforward Ok thanks for informing!!
@Mysterious_debris_1111
@Mysterious_debris_1111 2 жыл бұрын
Wonderful content. Thanks man !
@aswinaspirant4100
@aswinaspirant4100 3 жыл бұрын
Amazing brother !
@nileshsinha7869
@nileshsinha7869 3 жыл бұрын
Great explanation as always🔥❣️
@codewithme9016
@codewithme9016 3 жыл бұрын
That is clear 👍
@VirajChokhany
@VirajChokhany 3 жыл бұрын
Thanks striver. OP explanation 🔥
@gauravshukla6675
@gauravshukla6675 3 жыл бұрын
kabhi kabhi sochta hu striver bhai ko doubt ayega to vo kisse samjhenge
@satyampande684
@satyampande684 2 жыл бұрын
understood!!
@fardeenshaikh6434
@fardeenshaikh6434 3 жыл бұрын
Eid Mubarak Bhaiya
@PrinceKumar-el7ob
@PrinceKumar-el7ob 3 жыл бұрын
As perfect as always !!
@rishabhkumar8115
@rishabhkumar8115 3 жыл бұрын
if(like_button != 1){ while(1){ like_striver_video(); } } really, such a nice man you are and very very helpful.
@manasharsitraj3226
@manasharsitraj3226 3 жыл бұрын
Love you sir
@dhanashreegodase4445
@dhanashreegodase4445 2 жыл бұрын
why bfs? and not dfs
@vimalmaury9745
@vimalmaury9745 3 жыл бұрын
Why r u so awesome 🌝btw thanku so much keep helping us
@amansamal8233
@amansamal8233 2 жыл бұрын
understood❤❤
@radhe1335
@radhe1335 3 жыл бұрын
Striver OP 💥💥🔥🔥
@surajkumarsingh4857
@surajkumarsingh4857 3 жыл бұрын
Keep going brother 💯💯
@whatsupdiv
@whatsupdiv 3 жыл бұрын
noooo its over
@cy.sumit02
@cy.sumit02 3 жыл бұрын
Found u raja da It's Barce ❤️
@takeUforward
@takeUforward 3 жыл бұрын
Haha
@AshishKumar-pq6pr
@AshishKumar-pq6pr 3 жыл бұрын
Maja aa gya 😅🤟
@rajananarve5089
@rajananarve5089 3 жыл бұрын
Hi
@SahilSharma-vl9rk
@SahilSharma-vl9rk 3 жыл бұрын
Eid Mubarak bhai jaan ☺️❤️
@takeUforward
@takeUforward 3 жыл бұрын
Eid mubarak
@e889.
@e889. 3 жыл бұрын
💯
@saurabhsingh-sy4oh
@saurabhsingh-sy4oh 3 жыл бұрын
🙌🙌
@pabitradakua8113
@pabitradakua8113 3 жыл бұрын
Bhai 🔥
@kunalsihare5244
@kunalsihare5244 3 жыл бұрын
bhiya your voice is not clear bad mike quality
@takeUforward
@takeUforward 3 жыл бұрын
Okay bro. Did not find this feedback from anyone, still will get this checked! Thanks
@himanshu298
@himanshu298 3 жыл бұрын
Please enjoy your vacation instead of uploading videos..
N meetings In One Room | Greedy Algorithm
18:00
take U forward
Рет қаралды 196 М.
Median of two Sorted Arrays of Different Sizes | Binary Search
31:54
take U forward
Рет қаралды 240 М.
Kluster Duo #настольныеигры #boardgames #игры #games #настолки #настольные_игры
00:47
А что бы ты сделал? @LimbLossBoss
00:17
История одного вокалиста
Рет қаралды 10 МЛН
This dad wins Halloween! 🎃💀
01:00
Justin Flom
Рет қаралды 12 МЛН
Count Subarrays with Xor as K | This problem clears a lot of concepts
16:50
L4. Implement Min Stack | Stack and Queue Playlist
20:55
take U forward
Рет қаралды 37 М.
Imlement LFU Cache | Leetcode(Hard)
19:27
take U forward
Рет қаралды 124 М.
Implement LRU Cache | C++ and Java Clean and Short Implementation
14:03
Median of Row Wise Sorted Matrix | Nested Binary Search
28:42
take U forward
Рет қаралды 138 М.
Longest Substring Without Repeating Characters | Amazon
24:00
take U forward
Рет қаралды 291 М.
Minimum Platforms | Greedy Algorithms
18:41
take U forward
Рет қаралды 171 М.