Google Coding Interview Question and Answer - Most Stones Removed with Same Row or Column [LeetCode]

  Рет қаралды 23,690

Shiran Afergan

Shiran Afergan

Күн бұрын

Пікірлер: 108
@cs_soldier5292
@cs_soldier5292 2 жыл бұрын
Best channel to learn how to solve questions in competitive coding systematically.
@vinceluu
@vinceluu 3 жыл бұрын
Found your channel during my leetcode prep for interviews, super concise and clear explanations! Please keep uploading solutions!
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks Vince! I’m working on a new one. Hopefully will be up in a week or so.
@sahiljain2524
@sahiljain2524 2 жыл бұрын
Crazy Insaan!! you are great. The way you solve and boil down to a simple formula and make the question so so easy is so insan now i am fan of your hats off to you skills
@awfulprogrammer619
@awfulprogrammer619 2 жыл бұрын
I hope you are doing well. This is so great explanation! Keep Uploading and keep Shining!
@ashishkumarshrivastava2257
@ashishkumarshrivastava2257 3 жыл бұрын
Amazing explanation. The diagram you used to explain made it really simple to understand.
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks! I’m glad it helped :)
@Vishal_ingole
@Vishal_ingole 2 жыл бұрын
The way of explanation with visual effects is too good, Thanks for the video 😊
@deathstrokebrucewayne
@deathstrokebrucewayne 3 жыл бұрын
Your Explanations are just so great - To the point - No beating around the bush and extremely helpful. But you stopped making videos :( More power to you and may we find more such videos Admiration from India
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks Aadarsh! I didn’t stop, I’ve been extra busy lately but will post more soon :)
@manokumar89
@manokumar89 3 жыл бұрын
Thanks for an amazing explanation. 1. when you showed how the first example will work in a grid by removing the stones from 1.12 onwards, you are removing in the same order as if you remove the leaves from its spanning tree. how to actually go there? if we remove randomly matching stones, it wont end up with just 1 stone. 2. why the worst case complexity of naive solution is O(n2logn) if the amortized complexity of union-find is a constant: shouldn't the complexity be O(n2)? 3. what is the complexity of the final solution?
@jaideeppyne1880
@jaideeppyne1880 3 жыл бұрын
@Shiran Afergan There is so much clarity in your explanation! Superb.
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks Jaideep! I’m glad you enjoyed it :)
@jaideeppyne1880
@jaideeppyne1880 3 жыл бұрын
Cheers from India. Looking forward to more such awesome content.
@choicespecss
@choicespecss Жыл бұрын
Thank you for your videos and content stumbled across this video looking for union find solution to this problem. I hope you continue to upload videos and content!
@AnshulSharma-gq2vn
@AnshulSharma-gq2vn Жыл бұрын
Very well explained Shiran!! Kudos!
@satviksharma4897
@satviksharma4897 3 жыл бұрын
Oh lord how I have struggled with this problem, where have you been
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Haha glad it helped :)
@venkateshng2010
@venkateshng2010 2 жыл бұрын
I really enjoyed your explanation and the clean code you write, I am prepping for google interview next week, your channel came to me at the right time via leetcode discuss forum :) please keep making more videos
@ShiranAfergan
@ShiranAfergan 2 жыл бұрын
Working on it :) best of luck with your interview! 💪🏽
@beksultanomirzak9803
@beksultanomirzak9803 2 жыл бұрын
Astonish! thanks for your hard work
@shaydratler4777
@shaydratler4777 3 жыл бұрын
You are very Fluent and like the visualization Thanks for the hard work
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks 😊 glad you enjoyed it!
@senthilpalanisamy151
@senthilpalanisamy151 3 жыл бұрын
These videos deserve more views!
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks Senthil :)
@domod481
@domod481 3 жыл бұрын
Great explanation !! I really liked the way you explain the problem from scratch : ) Subscribed...
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thank you 🙏🏽:)
@nipunshah1373
@nipunshah1373 2 жыл бұрын
Splendid Explanation !
@Victoria-dk2jm
@Victoria-dk2jm 2 жыл бұрын
Perfect explanantion !!
@ShiranAfergan
@ShiranAfergan 2 жыл бұрын
Thanks :)
@akashkirthik9882
@akashkirthik9882 3 жыл бұрын
Amazing explanation ! Please keep making videos !
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thank you 😊 I’m working on it :)
@karanjkarnikhil4
@karanjkarnikhil4 2 жыл бұрын
What an amazing explanation !!!!
@ShiranAfergan
@ShiranAfergan 2 жыл бұрын
🙏🏽🙂
@codingwithanonymous890
@codingwithanonymous890 2 жыл бұрын
Explained so well.
@eg7eg7
@eg7eg7 3 жыл бұрын
Loved your explanation! thanks
@akshaygoyal2134
@akshaygoyal2134 3 жыл бұрын
Elegant solution. You have got a new subscriber :)
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks Akshay! I’m glad you liked it :)
@oknd6564
@oknd6564 3 жыл бұрын
Explanation is really awesome.
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thank you 🙏🏽 😊
@ujjwalchopra2880
@ujjwalchopra2880 3 жыл бұрын
awesome explanation thank you.. keep making videos
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks:)
@chris.w391
@chris.w391 3 жыл бұрын
Thank you! Well explained.
@parthghosh1343
@parthghosh1343 5 ай бұрын
thank you, great explanation
@aditya234567
@aditya234567 3 жыл бұрын
OMG ur very good at explaining
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thank you! I’m glad you liked it :)
@mlishka
@mlishka 3 жыл бұрын
Hey .. awesome explanation. Subscribed for easy explanation. Keep up the good work. Can you please do a videos on problem : region cut by slashes.
@domod481
@domod481 3 жыл бұрын
I am also looking for solution of this problem.
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thank you! Since it is also a union find question, it might take some time (i wanna do some tree, graph and recursion questions first) but seems interesting, thanks! ☺️
@chintamalli695
@chintamalli695 3 жыл бұрын
Awesome plz continue series with Google questions
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks! I will :)
@akashgupta6711
@akashgupta6711 2 жыл бұрын
Awesome explanation !! Can you please tell what is the drawing tool that you use ? I was thinking of using some kind of drawing tool for my virtual interviews.
@ShiranAfergan
@ShiranAfergan 2 жыл бұрын
It’s an iPad pro with GoodNotes
@musicperson94z
@musicperson94z 3 жыл бұрын
Awesome video. How can you be so good at this? Keep posting please.
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks Jiadong! You just need to practice :)
@mudrad1930
@mudrad1930 2 жыл бұрын
It really helped ! Thanks a lot
@ShiranAfergan
@ShiranAfergan 2 жыл бұрын
You’re welcome :)
@ishaankulkarni49
@ishaankulkarni49 3 жыл бұрын
great explanation! :)
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks :)
@deepusasidharan2012
@deepusasidharan2012 3 жыл бұрын
Good explanation
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks 😊
@interviewprep4181
@interviewprep4181 3 жыл бұрын
Really nice explanation
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks :) glad you liked it.
@adityamishra4458
@adityamishra4458 3 жыл бұрын
It was superb ..... can you suggest how to come up with such way of solving how you thought of this problem. Can you suggest some good resources to study for interviews
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks Aditya! I plan on doing a video with tips on how to approach such problems and maybe a series on data structures and common algorithms. For practicing I recommend LeetCode and GeeksforGeeks.
@manokumar89
@manokumar89 3 жыл бұрын
@@ShiranAfergan +1
@adityajagtap4349
@adityajagtap4349 2 жыл бұрын
I have been going through all you videos in the list . Thanks for sharing all the knowledge . I couldn't understand how groups were created inside a constructor of union find , like in example 6 groups are created upfront . I understand union like maintain parent as : (item index , parent value) . But couldn't really visualize when item itself is combination of two numbers.
@adityajagtap4349
@adityajagtap4349 2 жыл бұрын
But I got it now , item is row and column individually and instead of indexing with array which we have generally use , we have a map also we don't care about stone but only its cordinates . Being from java background parent[col] gave me feeling of index instead of keys .
@ShiranAfergan
@ShiranAfergan 2 жыл бұрын
I can see why it’s confusing:) I now code in Java in my job and I keep trying to use [] with maps and don’t understand why it’s not working 🙃
@akashingole
@akashingole 2 жыл бұрын
Hi, why have you added 1 to row and column.
@javierfuentes3603
@javierfuentes3603 3 жыл бұрын
great explanation
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks Javier!
@tsonnguyen
@tsonnguyen Жыл бұрын
ur the best
@akashjaiswal6478
@akashjaiswal6478 3 жыл бұрын
amazing explanation, thanks a lot, I have a doubt- when rank[xset]
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks:) it’s not an error because you only care about the rank of the root (the representative of the set) and yset is now under xset so we only need to update the rank of xset
@tom3983
@tom3983 3 жыл бұрын
amazing! thank you
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
I’m glad you liked it :) thanks for watching.
@nipunshah1373
@nipunshah1373 2 жыл бұрын
Why rank was not updated during merging in rest 2 conditions ?
@amanverma7375
@amanverma7375 2 жыл бұрын
I am unable to understand what does count variable stores initially, can we do count = stones. size(); as well
@harshk3351
@harshk3351 2 жыл бұрын
count will store the number of groups we have intially No, you can not do count = stones. size() this will be wrong just think over this example: [ [0, 0], [1,1], [2,2] ] here: count = stones. size() = 3 [WRONG] count = parent.size() = 6 [row0, col0, row1, col1 like that] [ CORRECT]
@DharmendraYadav-sf4ti
@DharmendraYadav-sf4ti 4 жыл бұрын
Nice Explanation
@ShiranAfergan
@ShiranAfergan 4 жыл бұрын
Thanks :)
@DharmendraYadav-sf4ti
@DharmendraYadav-sf4ti 4 жыл бұрын
Welcome!!
@eg7eg7
@eg7eg7 2 жыл бұрын
Watched that video again, and I was about to comment when I saw that I already did a year ago haha :P
@ShiranAfergan
@ShiranAfergan 2 жыл бұрын
Haha hope you enjoyed it the second time as well 😄
@eg7eg7
@eg7eg7 2 жыл бұрын
@@ShiranAfergan I did for sure :)
@ramanmanocha4800
@ramanmanocha4800 3 жыл бұрын
That's smart!!
@letslive3782
@letslive3782 2 жыл бұрын
How do you even get those ideas ? I could have never thought of this problem in this manner.
@ShiranAfergan
@ShiranAfergan 2 жыл бұрын
Yes, it is a difficult question. The idea is to try reducing the problem to something familiar. In this case - number of connected components in a graph.
@letslive3782
@letslive3782 2 жыл бұрын
@@ShiranAfergan Thank your very much, Shiran !!
@ritwik121
@ritwik121 3 жыл бұрын
can you make a video on this leetcode.com/problems/accounts-merge/ and can you more graph problems like this video. this video was very good. thanks
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thanks Ritwik! I like your suggestion, i will add this question to my list. I think the next one is going to be “robot room cleaner”. Hope you enjoy it :)
@ritwik121
@ritwik121 3 жыл бұрын
@@ShiranAfergan thanks a lot
@pwnweb5734
@pwnweb5734 2 жыл бұрын
Perfect. perfeect perfect peerrrfect
@ShiranAfergan
@ShiranAfergan 2 жыл бұрын
Glad you liked it 😆😊
@yash_______105
@yash_______105 2 жыл бұрын
@@ShiranAfergan can u plz plz increase frequency of uploading videos
@akshaykhanna4295
@akshaykhanna4295 3 жыл бұрын
So max stones that can be removed = Total stones - no of connected components
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Yup
@jethala138
@jethala138 2 жыл бұрын
You are beautiful ;) Btw Thanks for the explanation😊
@ShiranAfergan
@ShiranAfergan 2 жыл бұрын
Thanks and you’re welcome :) glad it helped
@shivamrai7838
@shivamrai7838 3 жыл бұрын
thankuhh :) -/\-
@garrettguitar6583
@garrettguitar6583 4 жыл бұрын
union find? Amortzed what? Too difficult . I m not smart enough for this. Too hard. Where can I find a simple explanation of this ?
@ShiranAfergan
@ShiranAfergan 4 жыл бұрын
Yes, it’s a difficult question. If you want to read up on union-find (Disjoint-set) data structure you can find a pretty detailed explanation on Wikipedia (en.wikipedia.org/wiki/Disjoint-set_data_structure ). You can also check out this Union-Find playlist from William Fiset kzbin.info/aero/PLDV1Zeh2NRsBI1C-mR6ZhHTyfoEJWlxvq
@praburajiiv
@praburajiiv 3 жыл бұрын
i came up with solution within 3 min of this video. good at explaining different test cases. curious to know your instagram id 😍
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Awesome :) thanks for watching. I don’t have an active instagram account.
@eVOLUC
@eVOLUC 3 жыл бұрын
babe
@shashanksinha6966
@shashanksinha6966 3 жыл бұрын
great explanation
@ShiranAfergan
@ShiranAfergan 3 жыл бұрын
Thank you :)
G-53. Most Stones Removed with Same Row or Column - DSU
23:51
take U forward
Рет қаралды 112 М.
Чистка воды совком от денег
00:32
FD Vasya
Рет қаралды 2,7 МЛН
From Small To Giant 0%🍫 VS 100%🍫 #katebrush #shorts #gummy
00:19
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
Data Structures for Coding Interviews [In 10 Minutes]
10:40
Shiran Afergan
Рет қаралды 44 М.
How to: Work at Google - Example Coding/Engineering Interview
24:02
Life at Google
Рет қаралды 7 МЛН
947. Most Stones Removed with Same Row or Column - Day 14/30 Leetcode November Challenge
16:05
Coding Interview | Software Engineer @ Bloomberg (Part 1)
30:05
Keep On Coding
Рет қаралды 4,7 МЛН