Acing Google Coding Interview as an 18 year old High School Student

Поделиться
HTML-код
  • Опубликовано: 2 май 2020
  • For my 50k subscriber special, I did a mock Google coding interview with Clement, an ex-Google engineer. As a competitive programmer, I have a lot of experience with algorithmic problems. Check out my channel to learn more about competitive programming!
    Check out the other Google coding interview on Clement's channel: • Google Coding Intervie...
    Second channel (William Lin ++): / @williamlinpp4187
    Website: williamlin.io/
    Instagram: / tmwilliamlin168
    Twitter: / tmwilliamlin168
    Discord: williamlin.io/discord
  • ИгрыИгры

Комментарии • 1,9 тыс.

  • @clem
    @clem 4 года назад +20226

    That ex-Google coding interviewer looked impressed! 😎

    • @pranjalsoni549
      @pranjalsoni549 4 года назад +388

      The frontend of algo expert is one of the best I have seen .

    • @riteshrastogi5388
      @riteshrastogi5388 4 года назад +156

      I am not saying that the third problem is easy ; It is tough ; I did remember when I did something like that for the first time ; yes ; indeed ; it was tough.
      But the fact is ; the third problem is trivial. It is famous by the name of "Re-rooting technique" in competitive programming ; and this is what tmw used ( Plus the problem is actually simple as compared to other rerooting problems out there )

    • @Clrkz
      @Clrkz 4 года назад +27

      @@Tacoslover770 lol 0:49

    • @kartaLaLa
      @kartaLaLa 4 года назад +22

      Want to see tmw interview you next time 😆 It will be quite fun and challenging

    • @rahulsbhatt
      @rahulsbhatt 4 года назад +19

      Yeah, I wonder who is he?😜

  • @kevindebruyne9218
    @kevindebruyne9218 4 года назад +5424

    He coded the RUclips algorithm to where more of his videos would pop up in your recommended.

    • @alibee2083
      @alibee2083 4 года назад +13

      William or Clement?

    • @SolomonBaka
      @SolomonBaka 4 года назад +72

      @@alibee2083, Clement, then William hacked it and corrected the error :)

    • @Mayank-hm7cc
      @Mayank-hm7cc 3 года назад +2

      @@SolomonBaka really 🤔🤔

    • @faustollapa
      @faustollapa 3 года назад +22

      Best midfielder in the world

    • @atharvabarsode8626
      @atharvabarsode8626 3 года назад

      If only it were that simple -.-

  • @arjay_2002
    @arjay_2002 4 года назад +6717

    interviewer: does that make sense?
    him: yeeehaa
    me: wtf jus happened

    • @vuger01
      @vuger01 4 года назад +15

      Same :D

    • @alphonsusho8962
      @alphonsusho8962 4 года назад +128

      Bruh I never even code and I watched this video, and was so confused all the way

    • @alanwake4537
      @alanwake4537 4 года назад +15

      @@alphonsusho8962 me too.. idk why this is my recomended

    • @artarkgaming5997
      @artarkgaming5997 4 года назад +31

      Alphonsus Ho Even If you were an experience programmer. He’s going extremely fast

    • @aiist6743
      @aiist6743 3 года назад +1

      @@artarkgaming5997 mashallah tbark allah alhamdulillah inshallah better astagfirullah

  • @limbolegs
    @limbolegs 3 года назад +4708

    (Me who knows nothing about coding): hmm yes yes that looks good

    • @dgaf2219
      @dgaf2219 3 года назад +34

      Same lmfao

    • @nuclearboy5714
      @nuclearboy5714 3 года назад +28

      All i know is simple css code 😂

    • @pranitp.1622
      @pranitp.1622 3 года назад +14

      @@nuclearboy5714 lmao same
      I feel soo useless now

    • @harsh4567
      @harsh4567 3 года назад

      Not relatable
      Flex

    • @drunkenone1699
      @drunkenone1699 3 года назад +4

      I only know the most basic stuff from C and Cplusplus

  • @aqib829
    @aqib829 4 года назад +6406

    Ok. William is being humble here. Pretty sure if this wasn't an interview he would have completed all the problems in 10 mins.

    • @Qizot
      @Qizot 4 года назад +389

      give him some vim and in 5 minutes he would be done

    • @El1as--
      @El1as-- 4 года назад +7

      Lol

    • @ivanp4740
      @ivanp4740 4 года назад +219

      It's okay.
      Actually, most of the engineers, who work in G/F can complete this in short period of time(this is as easy/medium questions from leetcode) but coding interview it's not just about problem solving. So... Sure, for competitive programmers of this level, this questions is very easy, because they are easy even for not competitive programmers :D

    • @durantburner7428
      @durantburner7428 4 года назад +282

      Yeah but in a company in the caliber of Google it isn't just about solving the problem, it is working with your team, explaining, and collaborating.

    • @atk_2815
      @atk_2815 3 года назад +65

      It’s an interview, it is just as important to explain your thought processes as it is to get it correct

  • @briandesign
    @briandesign 4 года назад +4767

    I have no idea what is going on, but I still watched the whole thing

    • @sidharth8823
      @sidharth8823 4 года назад +2

      Same 😂

    • @alexissorianooo
      @alexissorianooo 4 года назад +1

      same bro

    • @OFaruk58
      @OFaruk58 4 года назад +10

      This is too smart and handy for his age. Or I am too dumb for my age. Because I am also 18 but can not solve those things.

    • @edwardwang9209
      @edwardwang9209 4 года назад +4

      @@OFaruk58 I had 0 programming knowledge at 18 lol

    • @sourabhkhandelwal1568
      @sourabhkhandelwal1568 4 года назад +3

      Honestly although coming up with the solution is hard but understanding what he saying is pretty easy. So, I think this comment is sarcastic.

  • @matildapawlega8527
    @matildapawlega8527 3 года назад +6431

    Bruh I feel like a useless human watching this

    • @saint8350
      @saint8350 3 года назад +247

      This isn't the point of life

    • @badass6300
      @badass6300 3 года назад +168

      cuz you rely on school, universities and don't self-educate.

    • @farzankh
      @farzankh 3 года назад +5

      Hahahaha

    • @losasakarosa9050
      @losasakarosa9050 3 года назад +8

      You’re not!

    • @saint8350
      @saint8350 3 года назад +59

      God created you for a reason

  • @Datnigganeo
    @Datnigganeo 3 года назад +958

    I have no clue why I’m watching this and why I can’t stop as if I’m absorbing information, even though I’m fucking clueless as to what’s happening

    • @asian_buddie1405
      @asian_buddie1405 3 года назад +39

      That’s exactly what I was gonna comment 😂 literally watching the whole thing bc it’s just interesting how smart people talk to eachother

    • @Bigbossfredo_
      @Bigbossfredo_ 3 года назад +4

      Word^

    • @gamerplay8922
      @gamerplay8922 3 года назад +4

      I had no idea how to do this but listening to him explain it I was like o I see what you did like I was following along and understood. Nuts! Good communication on the code.

    • @hasannahle4687
      @hasannahle4687 3 года назад +1

      @lil clit7 absolutely yes, he is one of the finest youtubers in the world if its not him then who

    • @Joemels
      @Joemels 3 года назад

      I only understood the first part of the first problem

  • @weeeeeeeeeeeeeeee360
    @weeeeeeeeeeeeeeee360 3 года назад +549

    "Am I allowed to Google the solutions?"

    • @codycis
      @codycis 3 года назад +4

      This should have more likes

    • @birchtree5884
      @birchtree5884 3 года назад +11

      Programming in a nutshell

    • @necaton
      @necaton 3 года назад +6

      Google Interview in an nutshell

  • @Ultimaus
    @Ultimaus 3 года назад +1156

    This coding interview is so much more practical than regular interviews. Like where do you see yourself in 5 years

    • @fruitygranulizer540
      @fruitygranulizer540 2 года назад +46

      there are multiple interview stages, im sure they ask those kind of behavioural and other kind of questions in later interviews. they first filter out ppl through technical interviews

    • @angelachanelhuang1651
      @angelachanelhuang1651 10 месяцев назад +2

      law school is great for undergrad

    • @aaronhall1068
      @aaronhall1068 9 месяцев назад

      usually, at least for all the internships Ive applied to, its the opposite. Behavioral phone interview, behavioral interview in person / on zoom, then technical @@fruitygranulizer540

    • @LettuceLand
      @LettuceLand 8 месяцев назад +5

      Obviously this is a technical interview

  • @christianviray3176
    @christianviray3176 3 года назад +408

    *"The left property, the right property"*
    Me: Ahhh, yes its Real Estate

    • @nrr12k47
      @nrr12k47 2 года назад +1

      brooo that got me LMAOOO

    • @speisequark2
      @speisequark2 2 года назад

      it's free real estate

  • @earfquake3518
    @earfquake3518 3 года назад +771

    “They’re speaking the language of the gods.”

    • @sakibmullick
      @sakibmullick 3 года назад +2

      vegita found

    • @808.sfx_
      @808.sfx_ 3 года назад +1

      Literally what i was thinking💀

    • @dgaf2219
      @dgaf2219 3 года назад

      🤣🤣🤣🤣nah fam they alien 👽

    • @kelechidan2560
      @kelechidan2560 3 года назад

      @@sakibmullick 🤣

  • @DanT-iu6oc
    @DanT-iu6oc 4 года назад +2609

    > Solves leetcode medium
    > holy shit I'm so smart
    > goes on this channel
    > gives up, cries

    • @BaoGia-mi3pk
      @BaoGia-mi3pk 4 года назад +55

      life is not fair guy, get used to it

    • @ThatGuy56326
      @ThatGuy56326 4 года назад +144

      God damn 18 year old gets this problem instantly im sitting here like 👁👄👁

    • @hnwlightsugar2280
      @hnwlightsugar2280 4 года назад +69

      cant solves even the homework, goes on leetcode easy, can't solve it , give up, cries.

    • @bombbchu
      @bombbchu 4 года назад +59

      how long do you guys think he has been coding? Life is indeed not fair but you must understand that coding is a skill that takes years and years of practice to get to this level.

    • @ThatGuy56326
      @ThatGuy56326 4 года назад +82

      a_bombchu pretty sure his mom had a god damn computer in her womb

  • @Mockedarchie
    @Mockedarchie 4 года назад +267

    "Alright that was like a introduction question" ...... Me: "oh"

  • @gaoalexander73
    @gaoalexander73 3 года назад +531

    And hes a high school student, dang. I can't imagine understanding this stuff in high school.

    • @andyacevedo8270
      @andyacevedo8270 3 года назад +4

      Same here lol

    • @wolfgod1664
      @wolfgod1664 3 года назад +34

      You won’t I’m in high school and I didn’t even understand this lol

    • @ohreally4752
      @ohreally4752 3 года назад +13

      i’m in high school and i take some java programming classes and they still are confusing

    • @joejoe5081
      @joejoe5081 3 года назад +2

      @@ohreally4752 I think he uses c++ or c as his go to. Not sure though cause I found him recently

    • @k23180
      @k23180 3 года назад +1

      @@wolfgod1664 fr lmao

  • @ahsanali50
    @ahsanali50 3 года назад +363

    I have heard about only one tree in my life ; that is Christmas Tree 🎄

    • @shllyk
      @shllyk 3 года назад +16

      and family tree which i made in 2nd or 3rd grade

  • @bradvan8156
    @bradvan8156 3 года назад +1336

    Me: *furiously typing*
    Interviewer: what’s going on? I’m not seeing anything on the Google Doc?
    Me: *on stackoverflow*

  • @CarlosPerez-te4gx
    @CarlosPerez-te4gx 3 года назад +123

    Hey guys this is so legit I tested w Google interview and failed but the way this video is presented feels exactly how I felt during my interview. Good luck to you if you are planning to interview =)

  • @hesselbleeker6353
    @hesselbleeker6353 4 года назад +687

    i don't even know what he's doing but i like it

    • @user-sj2vp9mk5t
      @user-sj2vp9mk5t 3 года назад +10

      i don't even know what he's saying but i like it

    • @tejas1027
      @tejas1027 3 года назад +3

      @@user-sj2vp9mk5t i don’t even know what am I watching but i like it

    • @budjawa457
      @budjawa457 3 года назад +2

      @@tejas1027 I don't even know

    • @Slackful
      @Slackful 3 года назад +2

      @@budjawa457 I dont

    • @hermesingenui2653
      @hermesingenui2653 3 года назад +3

      I

  • @MriLevi2
    @MriLevi2 3 года назад +316

    So much fun to see. Still in my first year of studying programming, but it's so fascinating to see him think. Very organized way of thinking and obviously very smart too. Hoping I'll be as fluent with it as him in a few years!

    • @jaeseonghan1691
      @jaeseonghan1691 2 года назад +8

      hows your journey of programing going so far

    • @justyashin476
      @justyashin476 Год назад +8

      How’s it been

    • @OneLordeAnimeClips
      @OneLordeAnimeClips 7 месяцев назад +3

      @@justyashin476 He's too busy architecting a solution to the knapsack problem to respond to us plebs

  • @abdi6189
    @abdi6189 3 года назад +261

    Bruh im done, im currently in my second semester for cybersecurity and after seeing this im out

    • @SuperQuarterNote
      @SuperQuarterNote 3 года назад +16

      You can do it!

    • @houssam6249
      @houssam6249 3 года назад +11

      Don't give up bro

    • @kokonut5498
      @kokonut5498 3 года назад +4

      Bro giving up is the end of all ends. Just keep pushing even if u feel like ur not progressing

    • @varunk6633
      @varunk6633 3 года назад +1

      Just try to understand things topic by topic. You will be more brilliant than you know.

    • @nxh777
      @nxh777 3 года назад +1

      bruh don’t do it keep goin

  • @bradvan8156
    @bradvan8156 3 года назад +856

    *interview starts for Google *
    Interviewer: alright let’s get started
    Me an intellectual: can I use Microsoft Word instead of Google Docs?
    Interviewer: Get out

  • @miguelrevera6856
    @miguelrevera6856 4 года назад +80

    A more eloquent solution for Prompt#2
    For each node, add the sum of (original full tree) depth and re-iterate down to zero adding those sums also.
    e.g. Node#8: its original depth is 3, therefore we know it can be used in up to 3 (sub) trees, each time decreasing in depth. So the total from this node is 3+2+1+0 = 6. The same for Node#9. Node#5 would be 2+1+0 = 3.
    Add for all nodes and you get 26

    • @abhinavreddy3204
      @abhinavreddy3204 4 месяца назад

      yep i had the same idea, using a map we can store depths of every node from root node and then we can just do dfs from root node adding contribution of every node i.e n*(n+1)/2 , where n is depth of the node from root node .

  • @brettkruskie2699
    @brettkruskie2699 3 года назад +9

    After I watched your interview with Clement, I was so impressed. Your ability to solve this complex problem was very inspiring. You had me subscribed from day 1. Continue to code!

  • @Zorro9129
    @Zorro9129 4 года назад +717

    He is the chosen one to take down Google

    • @mr.washingtonsbuddy.8454
      @mr.washingtonsbuddy.8454 3 года назад +18

      You were supposed to destroy them, not JOIN them!!!

    • @Choconuss
      @Choconuss 3 года назад

      he looks like the lil Asian key maker in Matrix in that tiny room!! just way younger lol

  • @jazzymichael
    @jazzymichael 4 года назад +95

    I thought I was doing well because I could solve the first part... then they kept adding more and more complexity and I couldn't keep up lmao. I have to re-watch the second half of this video, great job.

    • @lilcraz851
      @lilcraz851 2 года назад +1

      At least u solved the first part

  • @---------------------------__
    @---------------------------__ 4 года назад +286

    11:56
    William: "Does it make sense so far"
    Clement: "Yes"
    Me: No. I haven't understood anything.

    • @inordirection_
      @inordirection_ 3 года назад +5

      It's okay, Clement said yes to keep the interview moving along but he was lost more often than he let on.

  • @DeadManRunning1
    @DeadManRunning1 3 года назад +286

    interviewer: "so now let's move on to something completely different"
    ...
    "so let's go back to that binary tree..."

    • @koshey245
      @koshey245 3 года назад +3

      Well to be fair it's almost shifting the entire try, so the tree isn't really static anymore persay

    • @shadon_official2510
      @shadon_official2510 3 года назад

      Lmaooo

  • @hontonix1413
    @hontonix1413 4 года назад +348

    Interviewer: *speaks coding language*
    Him: *explains coding*
    Me: yes that makes sense now

  • @codearabawy
    @codearabawy 4 года назад +13

    I'm happy for you, William! I wish you all the best :)

  • @junoc-s1720
    @junoc-s1720 3 года назад +353

    RUclips finding yet another way to make me feel like an idiot

    • @RSolfactory
      @RSolfactory 3 года назад

      Tbf it doesn't need much inspiration

  • @pilarmaealcazar5139
    @pilarmaealcazar5139 4 года назад +1

    Wow inspiring, more video like this please for learning purposes. Thank you! 🙏🏻

  • @leoxiaoyanqu
    @leoxiaoyanqu 4 года назад +51

    William is definitely being humble and acting like in a real interview (slow down and communicate). Great to watch. Thanks for sharing.
    I actually came up with BFS in mind first and wonder am I missing anything here if using BFS (for the first two prompts)?

  • @whitesalmon0925
    @whitesalmon0925 4 года назад +958

    as a high school student ???
    Me: OK, shredding my university degree right now.

    • @fjdjzfhrsut8063
      @fjdjzfhrsut8063 4 года назад +9

      Nah man at least you got a degree. :/

    • @coolmonkey619
      @coolmonkey619 4 года назад +161

      Lol. Too bad you can't shred your student loans too

    • @nightshark1156
      @nightshark1156 4 года назад +81

      That's like seeing Michael Jordan play basketball and then going home and burning your hoop! People are better at things than you, but that doesn't mean they're better than you.

    • @ralphlagos4210
      @ralphlagos4210 4 года назад +18

      He's been at it for a lot longer than most, so he deserves it. US Competitive Coding medalist.

    • @maplestoryinchinese
      @maplestoryinchinese 4 года назад

      @@coolmonkey619 LMAO

  • @CharlieAligaen
    @CharlieAligaen 4 года назад

    Just watched your Mock interview with Clèment. Great job! I'm very impressed. I started coding for fun. Subbed! Looking forward to your future videos!

  • @eccomusic1386
    @eccomusic1386 2 года назад +2

    wow Bro . William's voice is so soothing .
    I can listen to his voice at night and fall asleep . I'm not implying that it is boring , instead it is very relaxing and it gives me tingles (like ASMR) .

  • @matthewwatts2338
    @matthewwatts2338 4 года назад +3

    For the 3rd problem, since you're only asked to return the sum of distances to the target node, I don't think you need another dfs. In the first dfs you updated the target node with the info you need. So after dfs1, ans = p.second - (target->sz) + (p.first - target->sz).

  • @unconsciousmarty9393
    @unconsciousmarty9393 3 года назад +162

    And here i am 24 years old jobless getting rejected in all interviews

    • @xertz4267
      @xertz4267 3 года назад +30

      better days to come brother... many of us in the same situation. keep you head high!

    • @voltage3692
      @voltage3692 3 года назад +3

      Bhai koi baat hmare bhi din ayenge

    • @TapThatBootie
      @TapThatBootie 3 года назад +13

      Same here... got my bachelors back in October and still no job offers, only interviews with role play crap...

    • @sanjayk7661
      @sanjayk7661 3 года назад

      But your Sharma ji ka beta🙃

    • @CFCMAMO1
      @CFCMAMO1 3 года назад +7

      Keep optimistic my friend. It will come.

  • @thearlowolf7336
    @thearlowolf7336 3 года назад +2

    Idk anything about coding but this video made me want to learn how to code! I been trying to find a hobby but this is fascinating and fantastic job!

  • @justicewillprevail1106
    @justicewillprevail1106 9 месяцев назад +1

    Great job!!!! I see a bright bright future ahead of you.

  • @nursultandzhumabaev8943
    @nursultandzhumabaev8943 4 года назад +255

    Just imagine Clement wrote the problems in text with all the inputs...William would solve all of them like in 10min xD

    • @snehilkumar10
      @snehilkumar10 4 года назад +6

      Well, thats coding round. Its more like interview simulation. Interviewer dont give question in paper. They will give you example and then start with all your butt power..

  • @isaacmedlin1731
    @isaacmedlin1731 3 года назад +3

    I'm coming up in my senior year of college for software and I feel like I could of came up with these solutions but not nearly as fast. With a whiteboard and 3-5 hours it would be possible, but this guys quick with his thought process

  • @jatinkm
    @jatinkm 3 года назад

    You came up with the optimal solutions so quick!

  • @obamaobamna811
    @obamaobamna811 2 года назад

    Inspirational AF. Both of them hella good at what they do

  • @Holyblades1982
    @Holyblades1982 4 года назад +4

    I am sitting here at 4 in the morning and this came across my feed and I felt I had to watch the entire thing. I have been in IT since I was 14 and I will say I had no idea what the hell was going on the entire time lol. Took coding in high school but I knew in a few days it wasn't for me. Props to you man.

    • @soldiers303
      @soldiers303 3 года назад

      Same with me. First time I tried coding in Uni knew it wasn't for me. I guess it's one of those things, that you either understand or don't.

  • @nathanc9050
    @nathanc9050 4 года назад +59

    24:19 Clement smiles when tmw makes progress 🙂

  • @yousefbeiruty6417
    @yousefbeiruty6417 3 года назад

    That's a hard question good job I am keeping watching your videos are so helpful improving my skills in understanding problems.

  • @josephpark2093
    @josephpark2093 3 года назад

    I swear, I had also learned of everything in what was said here from an Algorithms book but I don't know it as thoroughly as him. I enjoyed this!

  • @Pensive_117
    @Pensive_117 2 года назад +3

    Practice and passion makes someone good at something? Woah, I would've never guessed.

  • @furroni9471
    @furroni9471 3 года назад +20

    Imagine being qualified for Google after High School. Nice work, I will follow your channel and see your progress, it's really interesting.

    • @user-gq7sv9tf1m
      @user-gq7sv9tf1m 3 года назад +5

      Being qualified and acing the technical part of the interview are different things

    • @jasonstarrising
      @jasonstarrising Год назад +1

      bro he is OVER qualified

    • @user-tz9jh6pv2j
      @user-tz9jh6pv2j 2 месяца назад

      @@user-gq7sv9tf1m You'd be surprised. I have a classmate at Stuy HS who graduated with us at 15... he went to MIT and finished by 18. We were class of 2008. He was a VP at Google by 22.

  • @pa8l0kool3
    @pa8l0kool3 Год назад +1

    im drunk rn but i will pay ALL my attention to this video, normally id for sure not watch this video bc of my pride but i LOVE this type of content bc i actually understand it. THANK YOU WILLIAM

  • @fernandomendes9914
    @fernandomendes9914 4 года назад

    Great Job William continue!

  • @zeroplays9915
    @zeroplays9915 3 года назад +16

    *I feel Like I got Smarter and big-brainier just by watching this guy ace this interview!*

  • @will-ye
    @will-ye 4 года назад +18

    The colab we never knew we needed

  • @mukulpanchakarla8944
    @mukulpanchakarla8944 4 года назад +1

    Keep up the good work clement..could you please make a video on commanly used approaches or ways to solve competitive programs with william

  • @richardhorvatichfittrader
    @richardhorvatichfittrader 3 года назад +1

    I wish you would make videos themed on how you got good. Timeline, skills acquired, projects from first to recent, how long do you practice daily, what have you studied, what do you suggest for people to get good or to your level?

  • @milochenmilochen
    @milochenmilochen 2 года назад +4

    For the 3rd question, even adding the parent node is helpful for using DFS/BFS to solve the problem, but your creative thinking for this question is so cool and the coding for the last question is so amazing. If the interviewee ask to figure out all sumDist for all node, then this solution only need O(N). But the way to add parent node will need O(N^2).

    • @karankumarmageswaran1550
      @karankumarmageswaran1550 Год назад

      adding parent node would be really helpful, but i'm not so sure an interviewer would allow it. the stuff he added can be directly calculated without changing the input type using functions he previously created. adding a parent node, however, cannot be done without changing the input, or creating a new function to store the parent node for every node

  • @video-vocabulary
    @video-vocabulary 4 года назад +47

    Finally joining William Lin Fan Club, I hope tmw spirit will give me strength

  • @pratickbhowmick4796
    @pratickbhowmick4796 Год назад

    Thanks, this was quite instructive!

  • @ritam8767
    @ritam8767 3 года назад +2

    The first question can be seen easily as a sequence. Each node in the rth row has depth (r-1) and there are 2^(r-1) such nodes. So it's just the sum of (r-1)*2^(r-1) where r goes from 1 to n, where n is number of rows. Correct me if I'm wrong.

  • @blameneeks
    @blameneeks 3 года назад +15

    That “and 5” really was his time to shine

  • @kakokapolei123
    @kakokapolei123 3 года назад +343

    11:57
    "Does that make sense so far"
    "Yup"
    What you don't see is him quietly going on StackOverflow wondering what the hell he just said

    • @joaolourenco5279
      @joaolourenco5279 3 года назад +4

      Dudee the kid is impressive considering the fact he is in high-school, but this video is what you learn in like the 1st year of computer science in like 2 chapters (graphs and threes) in the subject algorithms and data structures.

    • @putinsgaytwin4272
      @putinsgaytwin4272 3 года назад

      @@joaolourenco5279 how does this apply to software engineering?

    • @joaolourenco5279
      @joaolourenco5279 3 года назад +1

      @@putinsgaytwin4272 it's because you are manipulating data structures with algorithms, ex:heaps.

    • @Arobisme
      @Arobisme 3 года назад +2

      @@joaolourenco5279 but when I've been graduated for 5 years and haven't done a single thing with trees since then. I forgot it all

    • @tusharsrivastava370
      @tusharsrivastava370 3 года назад +1

      @@joaolourenco5279 no it's not... And also it depends on your own tendency to grasp that stuff... I had data structures and algorithms in my 2nd year of college( I'm in 4th currently) and 95% of my classmates still don't know shit about it .. although I'm pretty good at it but the teachers in my college didn't teach us how to code it... They just taught it on a theoretical level and expected us to code it out ourselves... well of course it's better doing it on your own instead of someone teaching you the whole code but this is one of the reasons my friends still don't know shit about it lol

  • @user-hc1hh8er6i
    @user-hc1hh8er6i 7 месяцев назад +2

    this guy nailed it easily .. he's young, sharp, still flexible .
    I wish parents was more caring about their children learning good stuff in their free time instead of wasting time on social networks and wasting time on other stuff ..
    this guy is amazing . I wish my kid one day will be even x10 sharper ! XD

  • @flandechocolate9675
    @flandechocolate9675 2 года назад +1

    crazy how freaking brilliant some people are

  • @ndntm
    @ndntm 4 года назад +79

    "just high school student" - funniest shit i've ever heard. Common high school student doesn't have almost 3k CF rating

  • @dimsumpizza4746
    @dimsumpizza4746 3 года назад +113

    This must be how aliens feels like when they hear our language

  • @AnRovik
    @AnRovik 3 года назад +1

    I'm actually a little jealous... I wish I had your passion at that age. Super impressive either way, you're an inspiration!

  • @tusharsrivastava370
    @tusharsrivastava370 3 года назад +10

    I'm 21 and pretty ok at programming, I'm amazed how fast this dude's brain works (talking about the rest of his kickstart videos cuz this one was pretty straightforward except the 3rd problem cuz it was genius of his to design that formula so quick). I wish I didn't go to college and instead I coded day and night to reach his level at that age lol

    • @letsgameco3514
      @letsgameco3514 Год назад

      So he did these challenges before, why he did it so fast :D So if you practice codewars a lot, can did the same

    • @alessiodaini7907
      @alessiodaini7907 11 месяцев назад

      don't worry these problems are easy and his solutions are more complex than they're supposed to be.

    • @MrTeslaX
      @MrTeslaX 4 месяца назад

      you dont reach this level by coding. William is a certified genius with very high IQ

    • @abhinavreddy3204
      @abhinavreddy3204 4 месяца назад

      for the 3rd problem you can simply do the bfs from the given node and add all the depths to calculate the final ans . the trick is to add parent pointer to every node similar to the left and right pointer, you can store the parent pointer's in a map .

    • @tusharsrivastava370
      @tusharsrivastava370 4 месяца назад

      @@abhinavreddy3204 thanks, but now that I’m working I realise worrying about all of this was pretty stupid. You barely ever need to make use of these irl… just like all those math problems where the character used to buy 1000 watermelons lol

  • @rexcchao1759
    @rexcchao1759 4 года назад +2559

    william seems to struggle with english more than the problems itself lol

    • @nexus5648
      @nexus5648 4 года назад +127

      I mean, English isn’t his first language so...

    • @mixedmaniac7957
      @mixedmaniac7957 3 года назад +140

      He's struggling with speaking itself more than the problem being language specific. The reason for that is because he's speaking while thinking of an actual solution to say on the spot.

    • @austindabomb9
      @austindabomb9 3 года назад +18

      He has better English than the interviewer or more understanding and that’s his second language

    • @nickwilson3499
      @nickwilson3499 3 года назад +102

      @@Milength when people ask him what languages he speaks, he says them in order of proficiency. First he says 1,200 programming languages then his native language then English.

    • @user-iy5zs4xs1n
      @user-iy5zs4xs1n 3 года назад +13

      @@nexus5648 it probably was im not sure. he got medal in IOI for the US and just graduated in Taipei American school(one of the most expensive schools in Taiwan)

  • @vaibhavmishra4505
    @vaibhavmishra4505 3 года назад +43

    For Prompt 2, an easier approach would be to find the depths of each individual node and just add their sums of AP up

    • @shivanshchakrawarti9289
      @shivanshchakrawarti9289 9 месяцев назад +1

      yes was wondering why he didn't do that , he just needed to update one line

    • @arthg893
      @arthg893 9 месяцев назад

      @@shivanshchakrawarti9289 can you explain that to me? i’m a bit lost, and if you could can you let me know how he added the mode depth and how they got 16 and 26

    • @brianchallita1050
      @brianchallita1050 7 месяцев назад

      The complexity of this algorithm would be huge

    • @shivanshchakrawarti9289
      @shivanshchakrawarti9289 7 месяцев назад

      No
      @@brianchallita1050

    • @RegisteredLate123
      @RegisteredLate123 7 месяцев назад

      exactly

  • @lakshyatripathi8624
    @lakshyatripathi8624 11 месяцев назад

    I could think of the first solution in about 5 seconds and I'm a happy person not even gonna watch the rest for a next few weeks unless I'm good enough to be able to do the second one too.

  • @doritos7134
    @doritos7134 3 года назад

    Thanks, I know a lot about the stock market because I self educated myself, right now I’m doing calculus in university and I’ll try to develop my skills and learn about coding. 😎

  • @amansinhparmar3336
    @amansinhparmar3336 4 года назад +178

    Clement is everywhere!

    • @tuanva6484
      @tuanva6484 4 года назад +9

      Like covid :))))

    • @kunal_chand
      @kunal_chand 4 года назад +12

      His connections are pretty strong.

    • @clem
      @clem 4 года назад +123

      I'm even in this comment thread! 😏

    • @54M4R7H
      @54M4R7H 4 года назад

      @@clem 🤯

    • @devendrasingh4776
      @devendrasingh4776 4 года назад +1

      @@clem 🤣🤣 nice algo expert...

  • @hpeets9116
    @hpeets9116 4 года назад +10

    Very entertaining William. I watched the whole thing, couldn't understand the other dude tho. I guess you should take the AP CS test for me now thanks!!!!!

  • @anonmuss7035
    @anonmuss7035 10 месяцев назад

    People like you (i.e., smart).....are going to change the world!.....I wish I could go back in time and start all over again....

  • @bigkurz
    @bigkurz 4 года назад

    Dang bro you killed that problem. Highly impressive

  • @SriNiVi
    @SriNiVi 4 года назад +6

    I did quite a few mock interviews from a few engineers from Amazon. TBH, if i aint doing it for the job, its really hard to push myself through the problem to get to a satisfiable approach with optimisation and stuff. But you did a great job over there considering you are really young. Envious.

  • @iskandarsiraj9627
    @iskandarsiraj9627 4 года назад +169

    I’m watching this while eating even tho I don’t understand nothing but deep in side hoping I can understand what’s goin on 😂😂

    • @humzauddin6692
      @humzauddin6692 3 года назад +1

      bro same. the guy says: yeeeaaapppp, me : hmmmm nice.

    • @bulldozer8950
      @bulldozer8950 3 года назад +2

      Exactly maybe I’ll just gain some of this knowledge just through osmosis. Kinda like trying to eat your study guide before the test

  • @andrewjulian7884
    @andrewjulian7884 3 года назад

    Wow i just spent my 48mins 57secs to watch the whole video and trying to figure it out! So helpful thanks 👏

  • @BuddyReviewTruyen
    @BuddyReviewTruyen 3 года назад

    U're really a monster algorithms and coding ... niceee

  • @amitnegi361
    @amitnegi361 4 года назад +7

    A much simpler solution for the second problem would be to just change one line of code from the first problem.
    ans += dep
    Becomes
    ans += dep * (dep+1) /2
    which is the summation of all number 1 to dep.
    The logic behind it is that the node at depth 3 will be part of 3 subtrees. And the corresponding depth of that node for those subtrees will be 1, 2, 3. Similar for nodes at depth 1 and 2.

    • @Eric-bp3tc
      @Eric-bp3tc 9 месяцев назад

      Thanks buddy, now kindly go back to being a neet

  • @bri-bri8536
    @bri-bri8536 3 года назад +4

    I had no idea what was going on...but i found it interesting and watched the whole thing

  • @kanishqprasad9378
    @kanishqprasad9378 Год назад +1

    I tried to do the same problems side by, i i literally took twice the time he took, with few errors. Literally, you are on the God level.

    • @keypey8256
      @keypey8256 Год назад

      It is possible to develop this kind of logic very quickly if you know where to look for problems. The problems he got are very standard/basic so he could have memorized a lot of the solutions as well. I personally have seen all of the problems he was given atleast 20 times before and I have only 2 years of experience in competitive programming

  • @jacksonrichter66
    @jacksonrichter66 4 года назад

    you're a super smart dude... big things are in your future

  • @yunfeiluo5613
    @yunfeiluo5613 4 года назад +28

    Thanks for the great coding interview. I tried to write my own solutions before I continued watching your solutions. And I just attached my codes here.
    Problem 1:
    Besides the ordinary dfs, I also wrote a one-line solution that works.
    int sumDepths(Node* root) {
    return root ? 2 + sumDepths(root->left) + sumDepths(root->right) : -1;
    }
    Problem 2:
    Actually, you can modify your previous dfs solution to get the answer. Suppose the node in the entire tree has depth 3, then node in the subtrees (including the entire tree) has depths 3, 2, 1, 0, sum to 6. That is true to each node. Thus,
    int ans = 0;
    void dfs(Node* root, int d) {
    ans += d * (d + 1) / 2; // instead of d
    if (root->left) dfs(root->left, d + 1);
    if (root->right) dfs(root->right, d + 1);
    }
    Problem 3:
    I wrote a one-pass solution, but it took me thirty minutes...
    vector find(TreeNode* root, TreeNode* target) {
    // 0: found target or not(0/1)
    // 1: number of nodes
    // 2: sum of dists
    // 3: dist to target from nodes above / for node below, we don't care
    if (!root) return {0, 0, 0, 0};
    vector l = find(root->left, target), r = find(root->right, target);
    // sum the distances we have so far
    int sd(l[2] + r[2]), da(0);
    if (!l[0] && !r[0]) { // haven't found target
    // add up extra dists to current node
    // which equal to the sum of nodes below
    sd += l[1] + r[1];
    } else if (l[0]) { // found target on left branch
    // update the dist from curr node to target
    da = l[3] + 1;
    // add up extra dists of all nodes on right branch to target
    // plus the dist of curr node to target
    sd += (level + 1) * r[1] + level;
    } else { // found target on right branch
    // update the dist from curr node to target
    da = r[3] + 1;
    // add up extra dists of all nodes on left branch to target
    // plus the dist of curr node to target
    sd += (level + 1) * l[1] + level;
    }
    return {root == target || l[0] || r[0], l[1] + r[1] + 1, sd, da};
    }
    int solve(TreeNode* root, TreeNode* target) {
    return find(root, target)[2];
    }

    • @yuvrajadkar
      @yuvrajadkar 2 года назад

      I have different simplified and smarter aproach to handle this problem.

  • @lonelypotatojinneverfound378
    @lonelypotatojinneverfound378 3 года назад +25

    "Does it make sense?"
    No, it doesn't but still gonna watch it

  • @NanaKwameAE
    @NanaKwameAE 11 месяцев назад

    I did understand most of it but this still inspires me to do more considering im starting highschool

  • @z08840
    @z08840 2 года назад

    for last problem - if you make tree non-directional (by adding parent pointer to each node) you can treat any node as a root for whole tree and apply solution of the second problem

  • @JA-jz2zj
    @JA-jz2zj 3 года назад +7

    he was hired at 30:10, jittery with voice change, lip bite, hair adjustment and turns of camera ... now that is nerd for love.

  • @getreadyforthepunch3474
    @getreadyforthepunch3474 4 года назад +25

    i really thought this was an *interview* oh well this just passed through my feed lol

  • @Minamoto321
    @Minamoto321 3 года назад

    Yes I have to say, you have good potential William....it's reminds m my day of first interview with Google ..."your potential will run"

  • @elohimgod2799
    @elohimgod2799 3 года назад

    People don’t feel bad some are just gifted in certain stuff, you are gifted in different ways, everyone has it’s gift.

  • @shikharsav
    @shikharsav 2 года назад +143

    I do work at Google (as or writing this), but these are my personal thoughts. First of all I want to say great job Clement and William. I have really enjoyed your videos and want to thank you guys for the great content. William, you are definitely impressive and have a very good chance of acing your Google Interviews if you choose to give them.
    One issue in these interviews is the subconscious bias - Clement knows how good William is so even though he tries to be fair and unbiased he is more likely to give William the benefit of the doubt than an average interviewee would get. For instance the solution for the 3rd problem has some issues - they are pretty basic ones and something that are trivial to catch if you're coding in an IDE (can you spot them?). Still that's something that I (and I guess the average Google interviewer) would bring up after the candidate has written code. Won't impact my hiring decision though.

  • @unmy400
    @unmy400 4 года назад +3

    and here i am, happy because I just moved a div to the center :)

  • @lotr_may
    @lotr_may 3 года назад

    Congrats William! You crushed it at IOI!

  • @abdelrhmanyasser8166
    @abdelrhmanyasser8166 3 года назад

    In the tree example with sum of depths of each subtree, I think you can add just the arithmetic sum of the depth at each node and that's it .

  • @MrBUDGIESROCK
    @MrBUDGIESROCK 4 года назад +50

    Im not the only one mesmerized by his pen flipping, right?

    • @casperd2100
      @casperd2100 4 года назад +2

      you mean... pen spinning?

    • @tackywacky99
      @tackywacky99 4 года назад +6

      every asian can do that. dont you know?

  • @masongligor9908
    @masongligor9908 3 года назад +20

    No idea why I’m watching this... but it makes me feel happy that there are such intelligent people out there!

  • @muhammadsalamy3292
    @muhammadsalamy3292 3 года назад +1

    For the first question , you can use BFS using some kind of queue , and when adding the children of some node to the queue , add 1 to the field representing the depth : (node,depth) pairs , having node x , or the pair (x,depth(x)) , add to the queue (x.left,depth(x)+1),(x.right,depth(x)+1) and then total_depths += depth(x)

  • @dharmeshharshwal5103
    @dharmeshharshwal5103 3 года назад

    This guy deserve more subscriber.