Coding Interview with Dan Abramov

Поделиться
HTML-код
  • Опубликовано: 6 июн 2024
  • #benawad #react ​

    ----
    Follow me online: voidpet.com/benawad
    #benawad
  • НаукаНаука

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

  • @b-b0t
    @b-b0t 2 года назад +4160

    the creator of redux taking so long to center a div gives me so much hope in my skills

    • @codeaperture
      @codeaperture 2 года назад +39

      😂😂

    • @youhabbo01
      @youhabbo01 2 года назад +31

      Hahahaha lol for real 😂

    • @gunarcom
      @gunarcom 2 года назад +62

      Ben had a shit-eating grin on his face.

    • @slimyslice
      @slimyslice 2 года назад +7

      😂😂😂

    • @nextentrepreneur9288
      @nextentrepreneur9288 2 года назад +57

      @Dyanosis He's been a senior fe engineer for years, he probably has a lot of experience with css

  • @stannone7272
    @stannone7272 2 года назад +1622

    Dear Dan,
    Thank you for taking the time to meet with our team about the [role title] role at [company name]. It was a pleasure to learn more about your skills and accomplishments.
    Unfortunately, our team did not select you for further consideration.
    I would like to note that competition for jobs at [company name] is always strong and that we often have to make difficult choices between many high-caliber candidates.

    • @afs35mm
      @afs35mm 2 года назад +81

      "...not enough positive signaling"

    • @lucamantova3070
      @lucamantova3070 2 года назад +183

      We cannot provide further feedback due to company policy.

    • @weiss588
      @weiss588 2 года назад +78

      that *Unfortunately* it scares me everytime

    • @fyfoh
      @fyfoh 2 года назад +177

      Unfortunately, we need someone with 15 years of experience with React.

    • @enfieldli9296
      @enfieldli9296 2 года назад +6

      ​@@fyfoh Heard that joke before, with different language context, can't remember which one tho...

  • @Nick-kb2jc
    @Nick-kb2jc 2 года назад +1376

    Wow, this Dan guy really has a bright future in programming if he keeps it up. Great job.

    • @pratyakshyt
      @pratyakshyt 2 года назад +40

      someone is goin to get r/wooosh

    • @VenkatGudavalli
      @VenkatGudavalli 2 года назад +27

      Loool he made future 😂

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

      Are you serious,?? The guy co created redux

    • @EgyptUnderGroundArmy
      @EgyptUnderGroundArmy 2 года назад +38

      @@muhammadssempala5143 First of all you just got woooshed, second of all Dan co-created JavaScript when he was..4? I think you mean Redux 🤣

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

      Lol, he made Angularjs

  • @muhammadirshadhusayn526
    @muhammadirshadhusayn526 2 года назад +486

    Huge respect for this man. He just came casually and did the very honest thing, knowing that he could get possibly judged by everyone literally for the div centering thing. Imaging having Dan as your co worker, I would never leave him as a colleague.

    • @goodbrainwork
      @goodbrainwork 2 года назад +25

      when you are making millions of dollars, you tend to not care about how other people look at you.

    • @brett84c
      @brett84c 2 года назад +16

      I also assume Dan spends the vast majority of his time working on logic and not styling so can't judge him too much.

  • @n8guy
    @n8guy 2 года назад +761

    How many companies would pass on Dan Abramov - THE Dan Abramov - based on his inability to quickly track down a rabbit in a contrived puzzle? This video *perfectly* captures the problems with front-end software interviewing today.
    Also, huge props to Dan for agreeing to do this. And for all he's given to the community. What a great guy.
    Also thanks to Ben. This kind of content can only improve the interview process in our field.

    • @fr5229
      @fr5229 2 года назад +37

      Companies don’t want a Dan Abramov. They want the kind of person who has really basic stuff memorized.

    • @Baaqel
      @Baaqel 2 года назад +9

      @@fr5229 i hate that you’re right

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

      @@fr5229 Exactly so let those companies fail, the certain companies that are smart would snatch Dan in a heart beat.

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

      @@_nimrod92 It’s not that the world is dumb and we are smart. Companies would rather have a person who’ll execute on their roadmap than unrelated things. They’re less likely to fail that way.
      People who can create, like Dan Abramov, would rather work for a company than make their own. Because they don’t have money.

    • @deanolium
      @deanolium Год назад +3

      The questions isn't really about finding a right or wrong answer, it's about seeing how they problem solve. Do they just completely shut down? Do they break the problem up into smaller steps which can be tackled? Can they work through with the interviewer to sense through the problem? That's really what interviewers are looking for on these type of questions. Of course, it is massively contrived and they can almost feel like the interviewer is trying to show off how smart they are. It's a hard balance.

  • @sbrugby1
    @sbrugby1 2 года назад +463

    The madman did it. He got THE Dan Abramov, defender of AngularJS, to come on the show.

    • @alimaxion2005
      @alimaxion2005 2 года назад +19

      Lol, it's React Js

    • @Spectraevil
      @Spectraevil 2 года назад +17

      Technically Dan himself tweeted about it. he asked random people in the world to interview him and Ben was probably one of the guys who was like yeah cool i’ll do it

    • @leandroamarillo3262
      @leandroamarillo3262 2 года назад +25

      @@alimaxion2005 no, hes referencing one time when Dan called out one of Ben's videos mocking Angular saying something like it wasn't funny nor good for the programming community to have that kind of videos that only cause infighting

  • @xit
    @xit 2 года назад +808

    Ben: There is a library called 'redux',
    Dan: "Hmmmm heard about it"

    • @xit
      @xit 2 года назад +19

      Mark: "Redux Toolkit is pretty awesome"

    • @nk4j272
      @nk4j272 2 года назад +40

      Also Dan: Redux? I never use that stuff

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

      This is funny haha

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

      😂😂

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

      One thing I learned from this video is ... well I didn't learn anything. This guy fell short of my expectations tho.

  • @grmancool
    @grmancool 2 года назад +181

    47:18 Dan on Slack: "sorry guys meeting canceled I have to catch a damn rabbit"

  • @anythingstudio5208
    @anythingstudio5208 2 года назад +388

    1:05 let & const question
    3:15 when to use redux
    6:40 What is dangerouslySetInnerHTML and when to use it
    11:00 Center div
    16:00 Binary Tree Question
    21:05 Bonus Question
    50:00 Bonus Question Best Solution

  • @faluhub
    @faluhub 2 года назад +202

    You can just see how excited Ben is for being able to have an interview with someone who created some of the libraries and frameworks he has used for so many years.

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

      Man! For 3 seconds I though you were the real Bill Gates. I was like.. OMG! kkk

    • @parablesboltnoel
      @parablesboltnoel 2 года назад +5

      Who else here read and interpret his name as Bill Gates after seeing his picture

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

      Pretty cool 😎

  • @squishydough2866
    @squishydough2866 2 года назад +47

    What an interesting video to watch. Really appreciative to have Dan Abramov willing to share his approach and thought process, as well as being willing to stumble with things on the fly - not easy to do at all! But seeing such an expert have some of the same stumbles as I do, as well as getting insight into a possible different approach to problem solving, is really valuable.
    Thank you both!

  • @ashatron656
    @ashatron656 2 года назад +258

    Gotta give Dan credit for this. Takes balls for a person of his reputation to get on stream an do this! 👍

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

      Gives me hopes that anyone can be a senior dev at a big tech company these days.

    • @chill-_-839
      @chill-_-839 2 года назад +3

      I do think his answers lacked any technical understanding of the questions though which is weird given his job background.

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

      @@juliansoto2651 If you can deliver value for sure, Dan sure has.

  • @brandonwie4173
    @brandonwie4173 2 года назад +13

    Thanks for both of you guys creating this unique collaboration content. I currently work as a front-end dev, and Ben's contents (React, TypeScript, libraries, and the list goes on) had helped me a lot along the way when I was studying to change my career as a developer. And Dan is my role model. I'm taking the course "Just JavaScript" that Dan recently released, and it's fantastic. I'm more than happy to see you both here in one vid and wish you all the best. Hope to meet you Dan in the near future as dev-to-dev if my dream ever comes true. I'll keep on studying and never stop learning :)

  • @bulbacode4380
    @bulbacode4380 2 года назад +266

    Now get one of the founding devs of Angular and make them do a React interview

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

      Could you call out at least one of them?

    • @ChauTran
      @ChauTran 2 года назад +26

      they probably write better React code than you

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

      it's a joke cause Ben jokes a lot about Angular being a shit framework

  • @eliseumds
    @eliseumds 2 года назад +106

    Wow, a professional mic makes so much difference.
    Well done, Ben!

    • @thesunrock
      @thesunrock 2 года назад +13

      When Ben leans back he is a bit hard to hear, whereas Dan's volume always stays stable. Personally, I prefer the latter.

    • @rendezvousonmemorylane
      @rendezvousonmemorylane 2 года назад +7

      @@thesunrock only u

  • @nstball18
    @nstball18 2 года назад +6

    This is awesome. Thank you for making such an awesome interview with Dan. Love how Dan thought and solved the Rabbit problem.

  • @creatorsremose
    @creatorsremose 2 года назад +13

    I love Dan... I love this interview. This has helped me so much with my impostor syndrome. I've been coding all my life and always dreaded algorithm questions in interviews. This truly helped me. ❤❤

  • @mlevel3041
    @mlevel3041 2 года назад +35

    The respect I have for Dan is huge. Can you see how humble and down to earth he is

  • @bmejia220
    @bmejia220 2 года назад +5

    Great interview Ben. Nice job with the rabbit question. It's cool to see an experienced js developer work through this tricky question.

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

    No way! Loved his Just JavaScript course!! Highly recommended!! Thank you for doing this!

  • @emmanuelmunachi1801
    @emmanuelmunachi1801 2 года назад +5

    Great interview Dan answered every question with humility.

  • @igorfv
    @igorfv 2 года назад +232

    Sometimes I forget that not all frontend/js devs are necessarily well versed in CSS. I remember the time that this center was actually a valid challenge

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

      thats why i ride with c/c++ for a while, before applying

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

      learning and implement dsa with weird language like js made my head spinning

    • @eccenux
      @eccenux 2 года назад +5

      Yeah, it greatly depends on what you are working with. And how many projects you do. In big projects sooner or later you have utility classes for most important things. Even if you written them yourself you just use them and forget what exactly was needed.

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

      It wasn't that hard even in the past. If I couldn't use flexbox then I'd do it like this in CSS:
      html {
      height: 100%;
      }
      body {
      position: relative;
      background: red;
      height: 100%;
      }
      div {
      width: 300px;
      height: 300px;
      background: white;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      }

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

      @@brianruff3066 Yep, that was basically the solution, the only thing is that we had to use negative margin instead of translate. Also, we had to write JS to get the width/height in case it was not fixed =/

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

    great job guys! congrats, more content like this, do a similar coding interview on react only, hooks, context and more.

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

    This guy is super down to earth! And Ben thank you so much for these videos, learning a lot

  • @FunctionGermany
    @FunctionGermany 2 года назад +11

    omg i never thought i'd see dan abramov center a div
    ben you are amazing, i love your style, and i also love dan and his great overreacted blog!

  • @claude.detchambila
    @claude.detchambila 2 года назад +30

    Wow that's a truly special guest.

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

    Before starting the video I hit like. This will be a nice treat! 🔥🔥🔥

  • @franson23
    @franson23 2 года назад +12

    Finished the 'Just JavaScript' course, made by Dan, about month ago. It helps me a lot, I was surprised, how many missconceptions there were in my understanding of JS. Thank you so much Dan, for this course and for your blog! Thank you Ben, for the great guest!)

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

      From where can I get that course?

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

      can I get link of that course please ?

  • @usmansbk
    @usmansbk 2 года назад +42

    Recruiters watching this are gonna start asking the Rabbit question because Dan and Ben did it.

  • @user-bh6mc8pd8g
    @user-bh6mc8pd8g 2 года назад +4

    wow, it was so interest, want more videos with Abramov .

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

    This was amazing to watch. I somehow had the impression that seniors or highly highly experienced programmers have no problem figuring out almost anything and that brought up some anxiety in me because I know I struggle with some aspects of programming.

  • @ryan.connaughton
    @ryan.connaughton 2 года назад +2

    Loved the rabbit question. Paused your chat and had a go myself before continuing =)

  • @gainadan-lucian2653
    @gainadan-lucian2653 2 года назад +9

    Great video, that bunny question was really something.
    When I heard the hint I thought about the same idea but the implementation was a bit different. I thought to double check each even number (skipping odd ones), and if no luck then start again but double check odd numbers (skipping even ones). Not a huge difference but I feel a bit proud of myself))

    • @Leo-ps4oo
      @Leo-ps4oo 2 года назад +1

      my first idea was to double check every number, that should work but checking even numbers first and odds second is better, but does not reduce time complexity, because the worst case is still the same.. am i right?

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

      @@Leo-ps4oo That's what I thought, just checking every value twice from 0 to 99 should get the result and has an easier implementation.

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

      @@vitorwindberg4212 Doesn't work. The rabbit starts at 2, you double check 0, then the rabbit jumps to 0 before you check 1.
      I do think there is a single pass solution but it is more complicated than this.

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

      @@NisJrgensen you are right, only works if you guess the rabbits parity, but then we go back to the original solution and have to go back and forth

  • @astritspanca2723
    @astritspanca2723 2 года назад +19

    Dan is the team leader I would love to have in my company

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

    loved this video! more of this should come in the future with Dan! :D

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

    Thoroughly enjoyed every bit of this! 🙌

  • @temirzhanyussupov6997
    @temirzhanyussupov6997 2 года назад +361

    This man is literally the god of JS and Ben is asking “let vs const” lmao 😂😂😂

    • @vexakul9536
      @vexakul9536 2 года назад +70

      And it turned out a good question to ask. He answered "I don't give a f*ck".

    • @adamferguson8611
      @adamferguson8611 2 года назад +13

      And he answered without a shred of arrogance.

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

      lol a god are you kidding me. His answer to dangerouslySetInnerHtml was embarrassing.

    • @tlthiem
      @tlthiem 2 года назад +21

      @@LuckyTechy dude this guy is literally a god full stop, lol. people so gifted often dont even think about the easy parts to an answer, because it is to trivial to them. This guy is the head behind react, cra, redux, and hugely influencial in the entire js eco system.

    • @And1997Ruz
      @And1997Ruz 2 года назад +18

      @@LuckyTechy right, you probably know better. Even though you will probably never be as accomplished

  • @jeremybuckets
    @jeremybuckets 2 года назад +12

    For the bunny question, you can do *slightly* better by doing a pass from index 1 to n-1 and then a reverse pass from n-1 back to 1. That gives you a worst case of 2*((n-1) - 1) = 2n - 4 guesses. Verifying this is left as an exercise for the reader.

    • @Daniel-rp4sx
      @Daniel-rp4sx 2 года назад

      this isn't a valid solution

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

      ​@@Daniel-rp4sx What about this: same solution as explained in the video, but instead, start at the center and make the reverse pass, then return to one hole prior to the center, and pass to the right. The idea being that you have a 50/50 shot at correctly guessing the side that the rabbit is in. I figure this provides the same benefit of the video's solution, namely, the benefit you get from passing through odds and evens, that is: having a 50/50 shot at correctly guessing the "side" (odd/even "side") the rabbit is in.

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

      that's still O(n)

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

    Thanks for the interview Ben and Dan. Really enjoyed it!

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

    this was actually really cool to watch thank you for sharing

  • @knuckleup9191
    @knuckleup9191 2 года назад +34

    ben seems more nervous interviewing dan than dan is being interviewed

  • @youtindia
    @youtindia 2 года назад +73

    The problem with tech interviews is that recruiters find problems like these (bunny) which are designed to gauge your thought process and instead using it wrongly to reject candidates. That's when you hear news like there's not enough talented developers, that's because you're gauging them wrong. If Dan can't solve this interview question then there's a good chance that a lot of bright minds might not be able to either, but that doesn't make them bad developers.

    • @Jamie-kf2vf
      @Jamie-kf2vf 2 года назад +16

      Been an engineer for 11 years and never encountered anything like this. I had a brief idea of how it could be solved, but I would probably have rambled on about it and bombed it. It's. It's not reflective of life as a software engineer.

    • @DauntingGecko
      @DauntingGecko 2 года назад +12

      Agree. Software developer in multiple languages for over 15 years here. Questions like this don’t really prove much - would you ask a mechanic to work through a very abstract scenario to prove they are a good mechanic? Nope. Programming is art and science…it takes time and many iterations to get to a solution to many challenges. Very rare you just come up with an immediate answer on the fly - takes hours to fully think things through before even coding some times. All this question does is show that the interviewers are novices and are likely seeking junior people as that’s what other companies do to hire their junior staff.

    • @Jamie-kf2vf
      @Jamie-kf2vf 2 года назад +7

      100%. The fact that Dan couldn't solve this is probably reflective of most of us here. And, also, Facebook would assess you on these questions during their process yet Dan works there and can't solve them himself so that's interesting to me. You're right though; they're gauging candidates on algs and ds that you wouldn't ever use in the day to day job. I've been in software for over 10 years and have never applied any of these dumb sorts of questions. When I was good at them I was studying them in university...11 years ago 🤣

    • @paulpavlinskyi4793
      @paulpavlinskyi4793 2 года назад +5

      Most of bright minds can’t under pressure of the moment.

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

      Some people who interview could be looking for things that aren't entirely related to the passing experience. If everyone interviewed were to "pass", the one who brings up something about say Coffee (when no one else did) wins, I made it up but hope you all get the picture.

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

    this is nifty. would love chapters/TOC for each question next time if you can

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

    this format is awesome!

  • @spillcode9462
    @spillcode9462 2 года назад +20

    This was really amazing. The bunny question seemed really tricky. And again, it's really looking at a person's thought process that matter in those types of questions.
    Dan is inspiring

  • @twenty9str498
    @twenty9str498 2 года назад +21

    In the last problem, you also need to check if the length of the array (holes) is even or odd. If the length is odd, you have to loop again with even indexes.

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

      thank you, I know I was missing something because I started with an array of odd holes and the solution of the video doesn’t assure you the right answer.

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

      I came to the same conclusion.

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

      Or you can start at pos=0 and check every hole twice, pushing the bunny to the end. Same performance O(2n)

    • @thetomking
      @thetomking 2 года назад +9

      @@MrThiteixeira if the bunny is at 3, you check 1 it moves to 2, you check 1 again, the bunny moves to 1, you check 2 for the first time and you've missed it.

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

      ​@@MrThiteixeira you can omit pos=0. if you check 1 and then 1, then if the bunny were originally on 0, you would always catch it the second time you check 1.
      same for pos=n. once you do n-1 twice, you can stop searching.

  • @alibaghban2934
    @alibaghban2934 3 месяца назад

    I enjoyed the video very much. I really love both Dan and Ben and They are great to the community. Thanks for the collab guys.

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

    You just made made day with this video :D and The Rabbit problem is really cool! Thanks Ben

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

      Btw, for div centering I always just set
      - flex-direction: row;
      - height: 100%;
      - justify-content: center;
      I think it's the simplest :D

  • @anthonyh618
    @anthonyh618 2 года назад +9

    This is great. Trying to figure out why watching other people interview makes me anxious...

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

      :D same

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

      Because we’re conditioned by our educational system to be afraid of tests? :-(

  • @Mal-wk3uq
    @Mal-wk3uq 2 года назад +10

    At first I thought this was a joke sometimes Ben likes trolling😂 , nice interview

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

    Awesome, just awesome Ben! Excellent job Dan Abramov!!

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

    Amazing video Ben!! 🌛🔥🔥💪💪👏👏
    Please more videos like that brother 🙏

  • @ozzyfromspace
    @ozzyfromspace 2 года назад +5

    Hey Ben, your purely intellectual bunny problem actually got me thinking about a solution to a graph problem I've been stuck on for like 2 weeks (not joking). So, thanks I guess. Also, you might find this funny but Dan inverted the tree real quick then took longer on the bunny problem. My situation was different: it took me a while to find a way to invert the tree using another method, but I solved the bunny problem in like a minute, with O(n^2) using a different method. I guess this is a reminder that if developers stick together and apply ourselves in sync, we can solve pretty much anything, given enough time. Glad to be a sub! Keep the excellent content coming, my guy 🎊🏆☮️🙌🏽

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

      Would love to hear your rabbit solution!

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

      O(n^2) is worse than brute forcing. How did you manage that? Lol

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

      ​@@Zeegonerif you make a 2 pass the worst case is n^2

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

      @@funprog You could check the each hole twice. So worst case is n+n. I don't think you can get any better than that

  • @quachhengtony7651
    @quachhengtony7651 2 года назад +43

    I'm using redux for state and saga for side effects. It's pretty cool to see the people behind the tech you're using.

    • @filcondrat
      @filcondrat 2 года назад +12

      pretty cool to see people who thinks there is no use for this tech anymore
      😀

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

      @@filcondrat wdym?

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

      @@quachhengtony7651 in second question, dan sounded like there are alot better options than redux right now to keep using it

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

    This interview just got me hype as hell!

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

    Awesome !!! Good to see Dan on

  • @thesunrock
    @thesunrock 2 года назад +15

    Ben, nice interview. Would have been also nice to hear him answer more short junior-middle questions, like "const vs let", to know what experienced people like Dan would say.

    • @eliotlnguyen7329
      @eliotlnguyen7329 2 года назад +5

      What... this is literally the first thing they chat about.

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

      wooosh!!!!??

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

      @@eliotlnguyen7329 you seem to struggle with the words "like" and "more"

  • @alexmorgan1030
    @alexmorgan1030 2 года назад +12

    Trying to place div in the center, took almost 5min from one of the famous developer, yeah, it's better than hundreds of motivation videos ;)

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

    Thank you for sharing this interview 👍🏻

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

    Love this! :D
    Feedback for Ben: your audio is much quieter in this than Dan so personally, I was doing a lot of volume adjustment up/down.

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

    Dan accepted! Amazing stuff.

  • @D34DTH1NGY
    @D34DTH1NGY 2 года назад +10

    One thing everyone seem to miss out, you have to have an exit condition on the recursive function call, right? Like checking on node.left exists before calling the invert function, since it would just be called infinitely often

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

      Yes, I was wondering about that too. Eventually the node you get would be a null

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

      came to the comments section to find this!

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

      Since he didn't check for null/undefined, the function will be halted by an error. invertTree(node.right) will never be called because an error will be reached when invertTree(node.left) recurses to the bottom of the tree and finds that it can no longer access 'left' of undefined/null. He's very close to the solution... he would surely realize what is needed if he were to run it.

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

      that is a huge mistake, I am impressed this guy(interviewer) did not care about it, one of the main features of recursion is the stop condition no matter the programming language..

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

    Enjoyed it. Thanks. I think he should add break condition for the inverted tree.

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

    Awesome i really enjoyed this interview with Dan.

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

    Watching Dan struggle with centering a div makes me confident in my front-end skills :)

  • @Filipemerker1
    @Filipemerker1 2 года назад +10

    Find someone that looks at you the way Ben looks at Dan coding.

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

    So this is a type of content I subscribed for

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

    we need more videos like these..

  • @ufufu001
    @ufufu001 2 года назад +42

    dan is such an interesting person. i love the stuff he tweets that’s not related to coding

  • @Voidstroyer
    @Voidstroyer 2 года назад +170

    Based on my experiences with interviews:
    1. Dan would have already not been considered since it took him so long to center the div.
    2. That invert binary tree function would error out when reaching a leaf node, and if by some miracle you had a binary tree that didn't have any leaf nodes, it would enter an infinite loop because there is no exit clause (checking for a null node).

    • @eccenux
      @eccenux 2 года назад +15

      If that is really the case then the interview system is very broken ;-)
      1. It was obvious Dan actually knew how to center a div in a "modern" way. Obviously you only do html,body style once per project.
      2. The function would break, yes. On any tree. So in practice it would be super easy to notice and to fix.
      BTW trees without leafs are not trees ;-) There would have to be a cycle in the graph. I'm guessing you know that, but just in case ;-)

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

      @@eccenux i agree with this. interviewers dont tend to hyperfocus on edge cases that are common best practice unless that it the point of a trick question

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

      @@eccenux Yes I know that trees without leafs don't exist and that's why I used the words "by some miracle". (maybe someone messed up the code and let one of the nodes point back to the root or something, but that's very silly and would never happen.... I hope).
      I agree with 1. But as I said, the issue was that it took him quite long. All of my interviewers consider it as something very basic that you should be able to do in negative 10 seconds....
      I live in Beijing, China by the way so maybe that gives some context as to what expectations interviewers have. It's very competitive. You need to pretty much be able to create your own operating system just to land that job where you will mostly be googling and copy pasting stuff. Also, all of my interviews are in Chinese and my Chinese is quite poor (foreigner living here).

    • @sqfzerzefsdf
      @sqfzerzefsdf 2 года назад +5

      @@Voidstroyer it's quite a bad interview question. what did you just write someone off for? for something that they most likely google in seconds and then move on to the actual work that you're paying them for? like problem solving, understanding requirements etc. remembering how all of these "basic" things work in every language, stylesheet, framework etc just isn't as relevant as being able to find their documentation, understanding it and actually producing good implementations.
      In fact why even explain it that much, a guy on the react team of all things getting written off should already explain why it's a bad interview question

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

      @@sqfzerzefsdf It's a problem with tech interviews in general. To be honest, a lot of these interviewers don't know what to ask, so they just use something as some leetcode problem because it's easy to do it that way. Of all the interviews I have done, only a handful of them actually asked me about my prior experience (I already had 3 years of experience when I did those interviews) and out of those, a few of them let me do some leetcode style questions before the actual interview.
      Some of them literally ask questions such as "What is the lifecycle of vuejs", which is something that you can literally google in 3 seconds. I dislike questions that have clear googleable answers. Leetcode questions aren't bad in that they can determine how the person thinks and the process of how they solve problems. But more often than not it is the interviewer that lacks the skills to do anything with that information. I also don't like not being able to google for answers during an interview, because you use it all the time during your actual job. I think that it should be allowed. Just don't ask stupid questions to which the answer can be googled.

  • @Narayanasuri08
    @Narayanasuri08 Год назад +2

    Dan seems like a top-notch dude. I wish I could have someone like him as my senior.

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

    Thanks for doing this Ben!

  • @kabal321321
    @kabal321321 2 года назад +14

    I solved the rabbit problem a little bit differently: I check the holes one by one sequentially starting from the 1st hole, but I stop before the last hole. I don't check the last hole at all, instead I check the last-1 hole again and then I start to check the holes sequentially backwards. If I reach the 2nd hole, then I'm 100% found the rabbit.
    How did I come to this solution?
    My idea was to take the worst case scenario: checking the 1st hole, but the rabbit is in the 2nd hole. Then I check the 2nd hole and the rabbit jumps to the 1st hole. Then I check the holes sequentially and the rabbit "follows" me until the last-1 hole. If I check the last hole then the rabbit can swap again the same way it did at the beginning. By skipping the last hole check and instead checking the last-1 hole again, I can know for sure that the rabbit is not in the last hole, otherwise with this 2nd check I would see it. If the rabbit followed me all the way, then it should be in the last-3 hole when I check the last-1 hole the 2nd time. If I start to go backwards from here and the rabbit would still follow me, then we would end up in the same hole at the next stop. But I'm thinking of the worst case here, so I assume the rabbit is running away from me at this point. If the rabbit would turn back at any point during this backwards chase, then we would end up in the same hole at one point. If I chase the rabbit all the way back to the 1st hole, then it has no place to go, but to the 2nd hole, which is my next hole that I check, therefore I don't have to check more holes.

    • @Italiafani
      @Italiafani 2 года назад +6

      I compared this to the solution shown on the video. I ran both solutions 100k times with a new random position on each iteration and on a set of 100 holes. Your solution found the rabbit with an average of 98.5 attempts, and the video's solution had an average of 99.6. Both solutions had a 100% success rate if anyone's wondering.

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

      @@Italiafani can you check this solution with starting from the second index instead of first? I wonder if it's going to improve

    •  2 года назад

      That's exactly how I imagined and found the same solution. Glad I found you in the comments and see you already explained it better than I'd haha

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

      Yeah this is what I was thinking!

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

      i was thinking of just starting from zero and check each hole i step on twice until n-1 and if i didn't find it until then i will find it at n-1 since he jumps back because he's at the end.

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

    By observing Dan struggle to center the div, I have promoted myself to his level in my head canon.

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

      Yes, but could you have answered the other questions as easily as he did?

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

      @@brianruff3066 No because I was being sarcastic. He is my father. If I was half as smart as him I'd be doing more complex things than centering divs. I struggle with medium difficulty and sometimes easy difficulty problems on leetcode. Help.

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

      @@mrdoner3451 It's okay. It's not like those questions truly reflect real life anyway. They are still fun to solve and if you can do them they will get you into some very high paying roles. Just keep working at them, and eventually, you'll get promoted. To be fair, the other questions were probably easier than medium-level Leet Code problems, so you still have that going for your at least.

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

    Thank Ben, thanks Dan! It was interesting.
    Waiting for the "Coding Interview with Evan You" %)

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

    Regarding the rabitt problem, you can use four pointer starting from the corners to the middle (two couple of poninters) then iterate each pair of pointer until they find each other, in that way you can find the rabbit in a O(n/2) complexity, I wonder if we can do it in log(n), not sure about that

  • @danilyanich
    @danilyanich 2 года назад +7

    Folks, do I miss something, or the invertTree function lacks the recursion exit condition? It'll just recurse until a crash.

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

      Maybe it depends what version you are using?

  • @Justin-fq8dt
    @Justin-fq8dt 2 года назад +3

    watching him struggle to center the div but then solve the binary tree inversion like that was surprising. he is obviously a skilled dev, im sure he doesnt write much UI

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

    Great interview!

  •  2 года назад

    Rofl that was both hilarious and super insightful!

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

    i feel like Dan has a great singing voice

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

      haha! thought the same thing.. reminded me of jeff buckley for a sec

  • @jdpt-
    @jdpt- 2 года назад +40

    The rabbit problem, it can be simplified down to 3 states as indexes: h, h+1, or up to h+n where h is the first index and n is the total number of holes minus 1. We can check for the rabbit at h. If the rabbit is at h, done. If the rabbit is at h+1, it can either go to h or h+2, so we check h again. If the rabbit isn't at h we know that the rabbit must be in h+1 or h+n, so h+1 becomes our new h while h is less than n. Basically just check each hole twice from the first hole, and you find the rabbit in less than 2n tries.
    EDIT: This assumes the rabbit can't jump from the first index to the last index and vise versa
    EDIT 2: This solution breaks at when the rabbit starts at h+3 as there is no first index the rabbit is forced against:
    | is a guess, ^ is the rabbit, & is the caught rabbit.
    h+0 h+1 h+2
    | ^
    | ^
    ^ |
    &
    h+0 h+1 h+2 h+3
    | ^
    | ^
    | ^
    | ^
    ^ |
    ^ |

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

      My solution just thinking would be to check even holes twice and odd holes ones.

    • @MrThiteixeira
      @MrThiteixeira 2 года назад +6

      Yes! I figured it out within a few minutes: start at pos=0 and check each hole twice. If wrong on the first try, rabbit is to the right. Check again, win or rabbit is still to the right. That way you are "pushing" the rabbit towards the end
      Probably much simpler to code

    • @tobyealden7263
      @tobyealden7263 2 года назад +16

      I thought this at first too, but if the rabbit starts at h+2, you check h and the rabbit moves to h+1, you check h again and the rabbit moves to h, you check h+1 and you've missed it.

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

      @@tobyealden7263 You'll miss it the first time you check h+1, yes, but the second time, the rabbit has to jump back from h to h+1, so you won't miss it. This is assuming it can't jump from the first index to the last index. Remember that h+2 is just (h+1)+1.
      EDIT I've just tried it out and yes you're correct, but it's at h+3 it breaks, not h+2.
      | is a guess, ^ is the rabbit, & is the caught rabbit.
      h+0 h+1 h+2
      | ^
      | ^
      ^ |
      &
      h+0 h+1 h+2 h+3
      | ^
      | ^
      | ^
      | ^
      ^ |
      ^ |

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

      @@jdpt- Yes, you're right in that edge case where the rabbit is at h (i.e. has nowhere else to go on the second check). So instead consider you start at h and the rabbit is at say h+4. You check h, rabbit moves to h+3, you check h again, rabbit goes back to h+4, you: h+1, rabbit: h+3, you: h+1, rabbit: h+4, you: h+2, rabbit: h+3, you: h+2, rabbit h+2 - and you've missed it. The subtly is that the rabbit can jump into the hole you just checked.

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

    Thank you Dan. We love you! ❤️

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

    Ben with the banger content, again!

  • @tresthegoat
    @tresthegoat 2 года назад +6

    Imagine your interviewer is smiling like a maniac and laughing while you are trying to work your answer lmao

  • @jperelli
    @jperelli 2 года назад +16

    18:38, not correct. Recursion has to be called only if branch != null, otherwise it will throw error something like "error trying to access property left of null"

    • @DanAbramov8
      @DanAbramov8 2 года назад +15

      Oh yea I forgot it's nullable!

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

      I teached programming in university for 5 years, I ended up seeing 3 basic rules for recursion to work:
      1. There needs to be a recursive call. I.e. call same function inside function you are defining.
      2. The call needs to be inside a conditional: if, where, ternary op, try catch, whatever
      3. The recursive call needs to have different arguments than the received, and each call should make the conditional closer to branch out of the recursive call, thus ending recursion, reaching the "base case"

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

    Very interesting interview!
    Anyway I have a question: was that div really pixel-centered (at 15:30)? The body has some default margins and it pushes the width/height in offset: in fact we can see the horizontal and vertical scrollbars. Just setting body "margin: 0" will solve it.
    Actually, in this way we don't even have to set body's width/height, but only put #root's width/height to "100vw/vh". Is this right?
    Also, about the "invertTree" function (at 20:50), don't we have to check if the current "node" is null?
    Since when a leaf is missing it's null, the first line would be to check this and return if it's null, e.g. "if (!node) return".
    Just very small doubts, let me know if this is correct or I'm going crazy.

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

      The last node will still have a value. So it will have {value: 'something', right: null, left:null};. So if(!node) won't work. You have to check if both right and left are null.

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

    Hey Ben, this is a really nice video with Dan!

  • @evgeniypp
    @evgeniypp 2 года назад +5

    Well, with the bunny you can just keep looking in one hole (the best choice is the middle one - 49). Eventually it will get there. Yes, I know it’s O(Infinity), so what? 😜

  • @bendevine
    @bendevine 2 года назад +7

    8:50: 'At Meta ... there's a match for dangerouslySetInnerHTML someone from security will be tagged on the PR for review'
    A lot of React's design decisions make more sense in the context of building facebook

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

      This made so much sense when he explained it, I will definitely suggest tagging people in pr based on what’s in the actual pull request

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

    I always use const. If the situation arises where I need to reassign the value, I first think if I should be doing that… or if another approach is better.

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

    Ben you did it, Man. Thank you 😁

  • @freshprince633
    @freshprince633 2 года назад +5

    Full disclose, only started watching the rabbit question.
    Initially, I thought checking the same index twice before moving to the next one would work, but the rabbit could be on the adjacent index when we check a particular index twice and jump over to the one we just checked, and we would miss the Rabbi.
    Now, the terms have changed and we know the rabbit starts off on an even index. In that case, start sweeping from 0 to n, and we should catch the rabbit. If the rabbit starts on an odd index, start from 1.
    This is provided the array is not looping, and once the rabbit reaches each end of the array, it has to jump back.

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

      Yes you can solve it if you check the same index twice, but start at an edge
      So check twice in 100.. if not found then the rabbit has to be at 99 or less
      Check twice at 99.. has to be at 98 or less..
      etc til you find it..
      Probably not very efficient but it took me less than a minute of thinking to come up with this?
      Am I hired? 🤩

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

      @@RobertFranksPlus initially, I thought the same too. But it won't work. Say the rabbit is at 98 and we checked 100, no rabbit. Then the rabbit moved to 99, and we checked 100 again, no rabbit. After that, the rabbit moved to 100, and we checked 99. No rabbit.
      So even if we do a sweep of the array, the rabbit can still jump through.
      But since we know the rabbit starts on an even number, we can start on the first even number index of the array and do a single sweep and always find the rabbit because we are looking for where the rabbit is.

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

      @@freshprince633 aah but the 2nd time we check 99 we would catch it!

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

      @@RobertFranksPlus That works if the rabbit is trapped at the end. Say the rabbit is at 6. We check 4 and the rabbit move to 5. We check 4 again and then the rabbit moves to 4. We check 5 and the rabbit is 4th hole. The rabbit has been missed.

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

      @@ImAfricanJesus exactly. Double checking an index is bit of a luck.
      But starting with an odd index when the rabbit is on odd index or even index when rabbit starts on an even number will surely catch the rabbit in a single pass (most of the time, before even completing a single sweep).

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

    On the bunny question, couldn't you find it in one pass by ''forcing'' an initial state on the bunny?
    If I first check at 1 -> the bunny could be at 0 or 2+
    Check at 1 again -> now the bunny could be only at 3+, if it were at 0 or 2 and it jumped to 1 then its over
    Now knowing that the bunny is forcibly at 3+, the odd naive approach should be enough to find it, should it not?

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

      Wrong my man! Consider rabbit starts at position 4.
      Step 1, check at 1: Bunny moves to 3.
      Step 2, check at 1: Bunny moves to 2.
      Now knowing your assumption for step 3 is that rabbit is forcibly 3+. But as seen in this one, it is not.
      Step 3, check at 2: Bunny moves to 1. And you miss it for rest of the game.
      Similarly it could happen for the following steps and the concurrent positions as well.
      That's the flaw in your logic, respectfully. :)

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

    Fantastic interview!

  • @Nil-js4bf
    @Nil-js4bf 2 года назад

    29:48 I spent 20min drawing out the scenarios and with a field of size 4, the guesses you make are 1,2,2,1. With a field of size 5, the guesses are 1,2,3,3,2,1. With field of size 6, it's 1,2,3,4,4,3,2,1. While I don't understand it deeply enough to give a formal mathematical proof for why it works, I would extend this to the solution where you guess 1,2,3,4....,98 and then 98,97,96,...,1. The way it works is when you guess upwards in index, it forces the possible positions of the rabbit to be in "alternating/interleaved" positions (possible locations of a rabbit can not be next to each other). Then as you guess from 98 back to 1, it takes advantage of those alternating positions and eliminates them 1 by 1. That's terribly explained - easiest to show drawn.
    This whole thing is possible due to the asymmetry of the boundary condition - when you guess 1, you eliminate the possibility of the rabbit being at index 0 after it made the jump. Then when you draw out the possible positions of the rabbit as you guess 2,3,...N-2 and you see that "alternating/interleaved" pattern emerging.
    Edit: saw the even/odd pass solution. I think it's very similar but it resulted in a good theorem: start counting from odd/even to catch odd/even rabbit.

  • @usmansbk
    @usmansbk 2 года назад +7

    Let's see Dan flip a tree

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

    he searched how to center div. I feel super safe ^^

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

    great video dude, helped me think outside the box

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

    ohhh nice :D ... would there be the possibility to have random coding interviews? I think would be funny. Super interview :D