Fake coding interview with Dan Abramov

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's see let's see let's see does it work okay hello then are you hey is that is that working i think it's working i i'm pretty amused because we didn't do like a sound check or a video check and if it works at the first time it's not the usual thing for me uh yeah people can hear you how are you uh pretty good just i'm on vacation so naturally i do some interviews exactly yeah well there's nothing uh better for a vacation or for holiest that taking like fake interviews in front of right now 333 people right nice so i know that you already had your first interview in this tour with ben and this will be the second one right or it was another one in the middle okay the second one no it's the second one yeah so i have two since here i i took a lot of information from ben's interview to try to get get you not i don't know if it's nervous but try to pin some of the pain points that you had on the on your first interview and i hope you had some fun in it i had a lot of fun doing the the exercise thank you excelov for the sub and let me it's too loud you don't hear that okay can you someone hear the sun you can where sorry there is a a car outside with a really loud noise sorry this is argentina before i can do nothing about it okay so let's look at it and we have an interview of three steps i will make you some random questions those random questions that usually appears an interview i will give you a challenge to that there are two exercises one of them is because you didn't want to wear a tuxedo so that was that it's a bonus um exercise and you have some algorithmic questions so we will do as far as we can in the time we have available and once we start the interview we will be how much time do we actually have at the time that you went if you are happy with it you will have a lot of time otherwise uh you will have a little in no time differ to you no i mean i'm not in the rush but whatever makes sense you decide perfect um so once we start doing an interview we are in an interview we don't know each other we are not in a stream this is a real interview just you and me and not the other people here so are you ready to go in an interview sure let's see well let's start the session here i will send you a link through oes ninja let me see let me know if oh wasn't the link let me know if you can open it yeah people is right probably i'm i'm more nervous than the people getting interviewed about people it's something let me see uh one second it asks me to sign in and i'm on a new computer so okay figure out how to do that right [Music] okay let me just log into github um i have like a lot of questions in here but some of them are like troll questions so i don't know if i should do all of them they're nice yeah we can do most of them okay i think it loaded yeah great let's show our screen then let's put some okay great well so we are now interviewing now uh hello i'm i'm going see i'm i'm sorry again i'm not gonna see i i'm gonna silence again and hello i'm gonzalo posso i'm from um a company called gonzaloposo and we are going through this interview this interview comes of three steps one is a motivation interview where i will ask you some questions uh that might be related to technology or not and then we will go through two challenges one it's a react challenge i think you have some experience at least is something i saw in your cv but we can talk about that later and we have some algorithms uh to see we will see how how you do with those exercises and if anything goes wrong or good we can continue with the other ones so we will start with the motivation interview we have some questions for you um and the first thing is before going to the first question tell me who you are uh what have you been working on on the last few years yeah uh so my name is dan i have been working at meta um been working on react itself so i guess for the most part like things like fix and bugs reviewing pull requests sometimes working on some of the new features that we're doing doing some kind of refactorings um a lot of work and communication stuff so like making sure that we can explain the things we're building that we have like a kind of a narrative a um you know like kind of like a messaging that resonates with people and that people understand like what we're doing and why uh admittedly not always great at that but i'm trying um yeah i think that's that's pretty much what i'm like for the past year i've been working mostly on the new react documentation so we are rebuilding the react docs uh there's a new version at beta dot reactors um so i've been helping build the website and also write a lot of content nice well uh this this new project we are hiring people for looks way more interesting so i hope you shine soon and well we're going to start with the questions then um tell me something new you have learned this week that's something i haven't wait so the week has just started right it's it's like tuesday and also i'm on vacation no no no but no i can't i can actually tell you something so i i did learn that well it has nothing to do with programming though i learned that there's a field called neura geometry which deals with how kind of the um how brain how the brain interprets uh like geometric structures like lines and you know like shapes and how they kind of get represented in like the visual cortex i don't understand anything about it but i i thought it was just fascinating that this field even exists uh so that that was fun well that that sounds interesting i don't know anything about it but i am always up to learning new things because uh i think you're okay um because always that you every time that you learn something new you you start like thinking how the things you already know can mix with the new things that you are learning and the next question it's a really random question and that that's a lot of assumptions but it's um okay do you want to read the next question a lot uh sure actually i'm curious am i supposed to look at the at your screen or should i open it you can open um the link i sent you the motivation interview md oh okay okay so the question is uh about the passport this question exactly okay you get a password for any country you like but you can't work as a developer you have all your current knowledge and you don't need license to work what do you do for a living okay let me think about this i can't work as a developer in that country or i can't work as a developer anywhere and i work remotely for another country you are trying to look for escape hatch no you can't work for a as a developer anywhere like you have to say okay i will be a teacher i will be something else than a developer in any country you want well can i not board but just play like can i and i work in open source and have somebody like sponsor me on patreon but it's not strictly seen work yeah of course you you can do whatever you want as long as you don't get paid like you need to do something else for a living that's not being a developer well what if i uh like i said what if i just work in open source but it's not work because i'm not employed by anyone and then i have like a patreon account where i say hey i'm unable to work so please help me feed myself uh because i work on useful projects you don't have to have escape hacks you have to choose a totally different thing like i don't know i will be selling lemonade on the beach like whatever you want you you want to yeah um i would maybe i guess i could just teach programming right so i could i could like uh make courses and which is what i already do right like i can make courses and sell them or workshops and it's actually like i i'd like to also do some kind of in-person teaching so that's something that i haven't tried but that sounds really fun even though it doesn't pay as much but it it's something that i'd like to try at some point well this question comes from a twitter account i saw the other day that was talking about what i want to do in the next five years right i want to be in contact with more persons i want to do something else so this is like the first part for the extra question that is also something really random you are the owner of a digital nomadco working in the middle of the caribbean sea people can't live so people it's in there it's huge it even have a lecture room a nightclub and a school which activities you will offer so people remain happy and motivated and of you and of course you are one of those persons um i find the phrasing digital nomad really objectionable i'm like like it just brings like a particular stereotype of like an annoying tech person who's realized that they can get like paid well anywhere and then they're being obnoxious in like different places around the earth uh so like if i if i imagine this like digital nomad co-working space like that just sounds like super boring because it's gonna be like all these people who think that they've got it all figured out so like i probably wouldn't want to uh to be with them and i probably wouldn't want to like if they have trouble with motivation and like they need motivation to uh you know like they need activities to stay happy and motivated like i think it's kind of their problem like i would kind of go the other way around like fake happy and motivated people and kind of just do whatever you know hang out with them and do what they like and i'm not sure it's so like i'm not sure all of these activities would be stream friendly so let's just leave it at that okay well that's okay um i had some extra questions and someone told me that you might have some experience with visual basic probably yeah yeah i i have some experience with visual basic 6 and also visual basic.net nice and how that lines up with you started in programming say it again uh how do you start any programming does visual basic uh goes in line with started programming yeah it was pretty accidental because i was preparing a presentation for school i think but i was always kind of really into you know like exploring all features of powerpoint so like i would uh like press every menu basically and i accidentally found there was a menu where you could like record something you're doing and then press play and it would do the same thing you record it automatically and also show you the code because it would actually capture what you're doing and like generate the code that does it and so i've never actually been exposed to the concept of code before so i wasn't sure what it's doing but i could see like the numbers and like if i change the number it would move the thing by different amounts i kind of figured out what it does and i learned that this is actually called vba so visual basic for applications and it's kind of like built into powerpoint and word than excel and a bunch of other microsoft products and i just bought a book on it and that's that's how i started learning that's really nice because i really love getting into programming because you want to do something and not just joining because you know what programming is i think that thing allows people to grow another kind of interest and last question before start working have you ever had impostor syndrome uh probably yeah i think i would i would say so i think it depends a little bit on the definition uh but like if did i feel like i'm surrounded by people way smarter than me like yes and actually like i am so hey i think like at some point i'm like no that's actually it's it's not like syndrome is actually a fact and like i'm okay with it um it's actually it's great because i get the yeah like i get to learn from them and but also like i don't i don't think i feel that the you know i think the bad part is like when you feel you're like you you're not being useful or like you're not you don't deserve to be there and i think i had some of that in the beginning and like for a while and i think with time i kind of uh like i saw that people appreciate like even though i'm not like the best at a bunch of stuff there are things i'm really good at and people do appreciate my input there so i think i just kind of learned that yeah like i'm actually good at some things and that's that's cool and i also have a bunch of experience that i didn't have previously so well that's nice uh yes everyone thinks that the other one knows everything we already know and more things and i think it's not that it's not like that like there's this bantam diagram uh going around all the things you know and the things the other people know and you have some collision in the middle um yeah although i would say that like it's also a bit naive like if you're if you're you know if you're new and you're you're actually like you do know less than other people like that's not it's not bad it's just yeah because that's you're new to the to the thing and so it's expected you will learn and kind of gain some knowledge and then get really good at it but it's it's okay that at some point you are actually less experienced it's not the syndrome it's just what it is perfect yeah well are you ready for the first challenge interview or you have to write something called um sure we will start with the extra question because of the tuxedo i think that you have a similar one this challenge interview it's about center the content so you have to center this high mount text in the middle and on the screen but you can't use flexbox okay uh where do i which file do i need to open you have to src dot dsx okay um i can't use flexbox well what can i change can i change like spam to div and so it's like your application you can do whatever you want okay uh yeah so let me first let's just oh i can't edit it says oh sorry about it give me the rights everyone gonna eat yeah right okay awesome so i'll just try to figure out uh okay this time uh just figure out where i am in the in the box okay um yeah let's go uh so let me let me center this thing so i think one thing i could maybe do is something like um i wonder if i can do this i'm not actually sure that this works but i'll give it a try so um what if i do something like this and this but also i think i need to do something like something like this maybe um [Music] yeah i think that i think that should be right because actually let me just verify that it makes sense yeah i think it makes sense perfect uh and i will make this one relative because because we don't know where where it's gonna be exactly which one is the most yeah great well that was really good um i wasn't expecting to to be so fast so points for you um well we can go to the second one do you want to read the second one aloud is on challenge interview the react file list challenge okay um okay this awesome feature called uh someone this is an awesome feature called server this is not true you'll quote me out of this and cut it out yeah i'll make it the production next week um it will not it's still going to be an alpha someone made an animated intro for the keynote presentation that sums up variable diffusion in 10 seconds showing a tree with different colors for client server components a client molecule text editor assigned you to work on the sidebar files theme they wanted to have a file3 component that shows several client files with different colors and correct indentation they left two mockup files the project for you to choose which structure do you prefer they said you can pick whatever file structure you want and they would affect everything they said based on your decision that's this show here in public we have a demo a image where you can see how it should look like uh the file list and you have the server files being in orange and the client files being embedded okay okay so let me uh let me have a look at the okay so i'm looking at the the json file so there's like one is normalized the other one is denormalized uh let me re-read again okay so the tasks list show folders and files with with list and list items files and folders should have correct indentation folders can be toggled okay to show hide their content okay yeah um what is the uh where is the how to make the app show up is oh i'm just working in this app this is that is that for us that okay so i just i just replaced this with the thing right the only thing i will ask you is like imagine that we are on some kind of a rupal interview workshop stream or whatever and there's people watching at you so you have to tell what you are doing so people can yeah sure sure so i'm just gonna get the data first just so um so that i can work with it uh i think i would have preferred nested one because the structure of the component tree kind of matches up the structure of the data i don't know if there's any downside to that but i'll find out as i go uh and i'll just kind of just kind of want to see lately here the thread um okay okay so let me i have this at the bottom so i don't forget um so yeah so it seems like i i want to show a um so what fields do we have so we have id file name children i don't know if something is a folder or if you actually i don't understand children wait i'm actually not sure and let me see the demo because uh yeah because i thought that you meant that the tree is gonna have like folders and then items inside yeah probably it's not what the trees yeah probably i have the other one modified because i was working on different files let me see yeah it doesn't have holders in the json yeah you can work with with that that's um i closed that one and i will modify the the file as you work but basically this is like the root folder and this is the app folder okay okay so i'll just say okay i'll just pretend okay yeah if it has children it's a folder okay okay yeah that makes sense um so i think i'll so is there one root note or are there many it seems like there's uh let me see so there's uh id1 okay so there is one root yeah that's kind of that's kind of a question to you yeah there's just one it's in nested it yeah you have only one node yeah you can remove it yes it seems yeah it seems like the array seems unnecessary so i'll remove the array um okay so we start with the root node so i'm just gonna write the component that i'll code node um it takes the so you can modify that data so we can later send it to the backend team and they will add uh sure so uh i'll start with the um so i'll start with the node and um so let me see again the node has a file name so um okay okay there's a bit of an annoying thing like for the root note uh depends of like how we structure it but if it's like a list item then there would have to be like a maybe maybe i'll just do this for now and then i'll think more about it like it would have to have a wrapper um and then another way would be to kind of rearrange them so i'll see which way makes more sense when i kind of get closer to this but i'll start with this so uh i have note that file name here okay so i have root and then i also want to have uh if there are children um so if well does the leaf node have again leaf node has children now so if now the children are not now we're gonna show a list and uh that would be a list of no children.map or each node i render another node so it has an id and it's the node itself well this is called node so i'm going to call this child and um typescript wants me to do something sorry i'll i'll look at this later um okay i i don't actually know typescript but i can probably figure it out later okay so um that's a yeah i know this doesn't work right um so it kind of looks wrong and i think is it is it the style language here or is it let me see let me just refresh this encounter with the children remember this key one how is that possible uh oh because this should be child okay okay it still looks wrong but i'm going to inspect it in the dom tree to see if it's the styling that messes it up or if it's if they're actually nested wrong so yeah it seems to be the styling somebody has some styling rules which uh yeah i think you have this uh yeah i'll just delete it because it seems like but it was make everything yeah it was the idea you had to go to that so okay um yeah and let me see again what you're aiming for um so okay so i'm gonna how close they actually do you care about this specific styling like they want me to replicate the mar exact margins and stuff or is it mostly just the things in the uh in the task like uh are clickable and different colors you only have to do uh well it's on the task otherwise all the other things that you want to do it they are okay but you only have to do those okay so um i'm gonna make i'm actually gonna split up uh this component because because i want the folders to be stateful and because they're going to be collapsible but files not collapsible and so it just seems like it makes sense to split them up and so um and also folders are the only one that have inner content so i'll just move this here and i'm gonna d if and the way we determine this is if no children is null we're gonna render the file and otherwise we're gonna render a folder and also because this can never happen i can delete this and here i can do this okay and then we want this to be um well wait no i messed it up somewhere because isn't showing why isn't it showing the um isn't showing the file name i think it's kind of guys [Music] okay okay yeah uh oh typescript would have helped me here right totally i don't want to say it but okay yeah maybe uh i just don't remember the syntax but yeah it's interface in that case otherwise if you want to use type you have to use evil okay so oh yeah i guess i i read about different smalls and i still have no idea what it is but let me just uh yeah so a d is a string and final name is a string and what else children is either no or it is i had to say it before but you have a types file in src that has all those types oh okay well um okay uh nested file plain file well i guess this is the file it's okay i'm gonna call this it's like both i guess that's that's node right essentially in my yeah okay import that's how you do it in typescript yep that's that's okay yes okay i don't know if this actually works this is the check no it was used before by the way okay sure i can ah this linter thing is is annoying because it doesn't actually like there's no way this would execute first so it doesn't matter i don't know why we have this interval turn them um anyway i'll i'll ignore the type stuff well it seems like the type stuff is uh and the input path cannot end with the gs extension okay is that does that make it happy okay it's possible well this is because the types are written this way like uh yeah i'll just i just want to get it working first and i'll think about types later okay um yeah so i want to use some state please and i want to put it into the folder so initially it is usually it's not expanded oh no it is initially actually expanded so um so what do you have in the picture yes i suppose you just want clicking on the thing to expand it um so i'm going to make it a button so that it's actually accessible but i want to kind of style it differently um so yeah we just want to toggle that and i think that oh and i i should actually use it so if it's if it's expanded i want to show all this stuff otherwise i don't okay that that actually works and uh i guess i yeah i will style this button later or i don't have to style it i don't think that was in the requirements and then i want the um what did you want you wanted the show in in different colors depending on the extension so i can do this in the file i can do um i'll just use blue and yellow i think that's that's okay we can say that it's it's like close enough and um so if if no dot file name dot ends with uh in your example i think it's server dot dsx or we could adjust it if we wanted to make it work with js but so far i think all of these are yeah i think that's let me let me double check the requirements so uh show all folders and files using ul and li i think i'm doing that all the folders should have correct invitation i think they can be toggled um server.js should yeah i think that i think that works excellent well i'm really glad that i i added the algorithms interview because otherwise this will be the entire interview and it has been just like 30 minutes i okay i can still fix some of the types if you want no no no we still have algorithms uh and that's okay if we finish with the inter with the algorithms in like five minutes as i probably expect uh because they're releasing and we can go back to it uh okay okay i don't think we'll be finished in five minutes with the algorithms they are i i looked for examples or algorithms that are like um not real world cases but that they are really easy to understand you don't have to have any prior knowledge or something you have access some files in the test file that discount solutes a valid parenthesis and vasya clerk and you have the address that in on top of it so you can just remove them skip you can start with whatever example you want okay okay so it's three different tasks and i can start with any rate exactly uh yeah i guess let's start maybe let's start well are any of them simpler than otherwise like i think i i would want to start with the simpler one but i don't know which one is something valid parenthesis is probably the simple one okay let's let's start there so uh they're saying i could remove the yeah okay i have the have the failing tests and then the the implementation uh one second let me just just uh yeah yeah sure um one second let me let me change the layout a little bit because my my screen yeah doesn't i don't see the whole okay so write a function that takes a string of parentheses um and determines if the order of the parenthesis is valid the function should return true if the string is valid and false if it's invalid um okay yeah that's actually a pretty cool task and i'm not sure how to do it so that's that's also cool um okay so i think um what does it mean for them to be valid it means that um let me just i'll just write some notes for myself valid lisp basically yeah so um yeah so if um left paren in beginning is valid but for example right paren in the beginning is not valid because we kind of if we were counting them we would kind of go into minus one and i think we're not supposed to go into minus one i don't know that would be sufficient um let me just yeah i'm just curious well i guess also if at the end we don't end up with zero that means that some have been kind of unclosed um oh does it is it valid the um yeah okay so this is also valid i can yeah yeah yeah so let's i'll just write the naive kind of implementation just based on kind of my my guess and we'll see if that that makes any sense so i would track how deep i am and um and for every character in the string [Music] i would read the character oh i'm sorry i used left here um yeah i don't care so so we take the character and if um if it's this i'll do something and if it's this i'll do something and i can just assume the string is valid because i think uh well i don't know well i guess if it's something else uh i don't i don't know if you can sit there like if i should like throw it here or something now just return false but you don't have well you did well interesting the example is fine okay i don't have any examples with bad inputs so i don't know what you want there well yeah the third one in the second one are bad inputs um the no no i meant something else but anyway let's uh yeah i'll just say i'll just say this for completeness um so if if we're going here we're increasing the depth if we're going here we'll decrease in the depth and i think if the depth um i think if the depth falls uh below zero i think that's bad i think it means that they're misaligned and i think if if at the end the depth falls below zero i think well if the depth is not equal to zero i think they're also misaligned um otherwise i think they're okay but that's just my guess it seems like i'm not well i'm passing some of them so empty string um we'll start at depth zero oh sorry this should have been outside the loop of course oh okay yeah i think that i think that works well that i wasn't expecting that because i know another solution uh totally different to what you haven't met but it looks i i can think more about it if it's not the most efficient one no no no it's it's pretty efficient and let's see you can see like the other solution like let's start with a valid case like this one like this one how do you know or which chunk you are sure that it's correct like it's valid well i would have to well i know that the the first one and the last one are valid so i could kind of recurse into that like if if the first and the last parent like open and closing then i can if it's valid if its content is valid and then the the base case is if it's empty it's also valid but then if if i can't take one of them so if it's like if it's not an odd number inside then i think it's not it's not going to be valid or if if the left and the right side are not parenthesis then it's also not going to be valid yeah there is a an easier uh chunk that it's valid that it's an opening right before a closing one a a closing one right after an opening one right yeah yeah and we already know that this chunk is valid right so what if we imagine that we are iterating this right we have this one and we say okay we know that opening and closing are valid now we can remove them and now we end up with opening and closing again and we remove them and we end up with yeah closing again so so i don't like this solution because we have to search for the same things multiple times and we also have to create like extra strings less efficient than just one traversal exactly what you may hear it's way better than that solution and when you started doing this part like when you reach it here i say hey this was way better than what i expected but well uh just so people understand what that normal person will try to do um so i hope it's correct because i don't actually know if like my solution misses some cases but at least it passes this test yeah i just put some examples that they are the ones the original ones but i haven't tried with other random and it was really nice so uh this one it's the middle one before the the none of them are really complex right but we can continue with the count salute one okay um so let me uh let me reformat this slightly because i can't really read the whole thing without wrapping okay there is an error hallway in which people can go right and left only well that sounds really claustrophobic um when two people meet in the hallway by tradition they must salute each other people move at the same speed left and right i don't really understand this yet though i'll just read it and then yeah it will make sense later it asks us to write the function the given string representation of people moving the whole way we count the number of solutes that will occur note this list occur when people meet one to the other and vice versa people moving right will be represented by right arrow people moving left left will be representing the left arrow example input would be like right there's dash this represents empty space which you need not worry about okay um does it make sense now no but i'm looking at the examples so so two people moving right we'll meet two people moving left oh okay so the total four meetings will occur if eight salutes will occur okay so the number of salutes is just twice the number of meetings always because we assume that they both are able to sell it um okay and here two people moving right we'll meet the people moving wait oh i see so there's uh these people are moving away no wait which which other ones are going to meet now uh remember that every time someone meets it's absolute from oh okay okay uh i think i'm just confused why it says right above hence a total of four meetings will occur but it says the output is two uh now in this case uh like this oh this was explanation sorry this was for the previous one exactly and this one goes to this one okay yeah sorry i i thought that this relates to this okay so let me just re-read it now because i think i understand what they're saying so there's an okay so okay so the things can move in two directions when things uh they don't have any specific speeds or like they're they're all going at the same speed i guess exactly yeah it's a um yeah yeah so if they move into the same direction they will never catch up so the only case where they meet is actually if they're looking at each other so whatever what we're being asked to do is count how many uh how many pairs of these things are opposite to each other i think that's that's what it's asking because like here for this thing so we have like here's sorry here is one pair here is here two this is pair three and this is pair four and here the only pairs that are looking in directions are one yeah this one pair okay so i count the number of pairs looking in looking at each other and i multiply that by two and that is the answer so um interesting so i think the first thing i would want to know is just well i guess it's what does it mean to look at each other it means that they have to be that's pretty deep right uh well it means that the the left one is the one that like the uh greater greater than and then the right one has to be the less than and yeah i think that's that's what it means uh yeah i'm not sure what's the most efficient way to do it yeah or you can maybe start you can do something and if you find a way to do it like the best way possible yeah i think i think i'll just start with uh i'll just start with some naive approach and maybe i'll think of like a better approach as i understand the problem better but it would just help me to actually start coding instead of you know just only thinking about it and maybe this will be my downfall but well i guess still let me let me kind of think about it a little though that's a random fact for this exercise there's a really narrow hallway in amsterdam uh that was where this exercise was based on uh and people usually read each other when they go through it okay that's that's this is cute um so so i think the most naive approach would be to find all the like to record positions of all the greater than arrows arrows and then record positions of all the uh less than arrows and then loop through like each of them like kind of squared so like for each for each see if uh if yeah i'll i'll i'll maybe do that and see and see if this works and then i'll think if there's any way to optimize it um so um [Music] so i'm going to do a single pass on a string and i'll just record so if it's it's this thing then i want to um yeah i want to push its index or if it's this thing i want to push its index as well and so by the end of this i have to erase um just gonna i don't know is it is that that's how you focus on the test yes i think so um so i'll just just look at what's going on here um does it is it brings okay there's a concept yeah okay it works so we have the 0 9 13 and this is like zero yeah and then yeah okay so for um so for each for each um thing in the left arrows i want to take a one of the right arrows and then if so i'm not interested in the ones uh that to the left so if um if right if right index is yeah so if the right index is the left of the left index i don't care about it if it is to the right then it seems like a valid pair so i think i think i might want to increment this uh and then maybe i return this multiplied by two but can i maybe just return this it somehow fits i don't know if i just no this isn't right okay um okay but but one of them is right so let me see what's all two of them are right let me see if it's an accident or if i'm onto something so this one has a lot of right arrows and it has one okay so for each uh okay so let's focus on this test so uh left arrows right arrows what does it say so left arrows is 25 wait this is not right uh i'm not looking at the right thing did i confuse left and right ones so oh wait left wait left error yeah i got confused by naming so the arrows point in the left arrows is other things pointing to the left so the left arrows are currently at the right right yeah so i think i want to swap left pointing right yeah so i think i i actually i guess this doesn't actually matter which but i think just i was kind of thinking about this way just more natural for me so so for each right pointing arrow take a left pointing and then if the left pointing arrow is to the left of the right pointing arrow i think i i don't really want it okay so this is where the times two disappeared it's actually it was actually needed yeah that works well i should kill the console log but i don't know if it's the most efficient way it's gonna like i'm not a huge fan of the n squared it's okay there is always that person in code words that solves the gata with a regex but uh you have always another way to do things i think it's it's really okay and my solution of course uh for this thing was really similar to the other one but of course it's not like efficient that it was basically removing all the white spaces in this case and say okay every time i came around of one of these i will just say okay this one goes to there and i will get every time they meet each other in this case it was just one so i will output two in this case you will say same thing like you have this one remove one remove this remove this and say okay i have this one yeah same thing i see you're kind of simulating them actually walking exactly right that my brain needs this like kids think that you have to see the result otherwise i can like make up all the entire scenario like you live on my head yeah as well one of the solutions and so this third exercise it's also like this like you can't do the solution as you're asked the r2 but it's something like a real case scenario and do you want to read this aloud yeah let me let me also split it up a little bit we don't have like a button to wrap the text okay um okay so the new avengers movie has just been released there are a lot of people at the cinema box office standing in a huge line each of them has a single um well i guess this yeah so i yeah a single 150 or 25 dollar bill and the ticket costs 25 dollars so vaca wants to sell a ticket to every single person in this line invoice is selling ticket to each person and give the change if he initially has no money and sells the tickets strictly in the order people follow in the line return yes if you can sell ticket to each person and give the change otherwise return null okay let me just uh try to figure out the example so so the line is 25 25 50. yeah okay so vasa has no money initially exactly so if i say get gets 25 25 they have 50 and uh wait whoa let me appreciate this oh okay so each person's buying just one ticket exactly um and so in this case advice is able to help the third person because he needs to give 25 back and he has a 25 bill whereas in this example uh avacya gets 25 and then he needs to give back 75 but he doesn't have 75 so he's not able to do that exactly and then here apparent 25 50 25 100. that should be fine yeah so at some point i guess this breaks down but i don't know where so okay um let's let's unskip it and let's uh let's just start with this case i guess uh so interesting so i need to track how many bills of each currency i i have and yeah kind of hardcoded like three variables i have a map i don't really have three predefined well i'll start with three variables i'll maybe change that to map later so um i'll say i'll have like three variables like count of 25 out of 15 kind of 100 notes in the beginning we don't have any and then for each uh each incoming bill um we want to see so we know that um um that was the english word does it change like the thing you return yeah it's change yeah so this is uh bill minus 25 which is the cost of the ticket and if yeah so basically i want to have i want to see um [Music] well i'll just write if change is is 25 and i don't have 25 notes then things are bad and similarly if i same okay this doesn't quite make sense actually because uh for example change can never be hundred because there's there's no such thing as yeah i think these are the only two valid cases um [Music] so if change is 25 which is basically if they're given 50 changes 25 i've run out of 25 notes then for screw it if change is 50. well change cannot be 50 either but it could be 75. it will be 75 yeah it could be 75 so if it changes i know there's some more generic way to write it but for now i'll just because we have three kinds of banknotes right uh and we have just one price which is 25. so the only cases are no change so if well chance 25 and 75 yeah i don't know if there's anything to do here but i'll just kind of add some structure so uh if yeah so if um 75 then i have to have uh either well i actually have a few options here and that's kind of interesting yeah so so i could have [Music] again i'm kind of writing this in a very manual way maybe there's some more generic way to write it but let's say um what are the it seems like it's actually easier to express um in terms of good cases rather than bad cases so if yeah so i'll as i'll slightly restructure it for my own sanity so if the change is zero and i'll need to keep track of the bill i got but for now if the change is zero i don't need to do anything if the change is um 25 then if on 25 is more than zero then we're cool if the change is 75 then if um if we have at least three of these we're cool if we have um at least one of these at least one of these were also cool i think in other cases were were not we're not cool so uh yeah that is it that is a case where we are going to know and we also need to actually keep track of um uh we also need to keep track of the the thing we just received right so that's um yeah so i could do this either before or after i don't think it actually matters uh but i think it's actually um well no it matters because i have continued here so i can't actually escape this so i want to do this here so um well but i don't want the motive like i want to use okay maybe my structure was bad after all because i don't i don't want to exit the loop without without adding it to the balance so i think what i'll do is restructure this again but i'll i'll assume but not okay i'll say this is okay this is okay this is okay this is okay um we're not okay we can exit right now and also i want the now um so if the bill is in a5 i'll do this the bill is 50. i'll do this and if the bill is a hundred doesn't really matter we don't use the hundred pills anywhere but okay but you always want to know how much you have right um yeah so this doesn't work still right so let's um let's dig into why this doesn't actually work uh i think i still have some console logs from another task let me or where are these the old blocks okay yeah these are the old blocks this is it doesn't work um let me kind of just go through it first so uh 25 25 50 so we start with 25 i assume okay is false change is 25 minus 25 is zero so k is true not okay okay bill is 25 now kind of 25 is incremented we go to the next one then i do 25 again this is one okay i'm too lazy i'm gonna cancel all this so um bill is this and then okay and let's reset this okay so bill is 25 i'll also add this okay so bill is 25 before it was zero now we have one bill is 25 wait wait the base case should be yeah but yeah okay so this one doesn't work i'm glad that you didn't make this one in like five minutes like the other ones because at least we have some more content yeah so let's see uh this one is kind of annoying because i don't know why um because i i don't obviously see why this one is wrong either but i guess i'll just i'll just read through it and see where it kind of breaks down um okay so we started bill is 25. uh now we have 125 bill then the next bill is 50. we used to have one no when i give change i should spend the bill so if i i can give you a hint because this is something that happens a lot if you are going to buy something like you you are the clerk you have to give the money back to people and you have two options like the option in line 40 and the option line for the e4 sorry the option in line 44 and the option in line 47 which one will you do first and why uh well i guess i would do this one first because uh well because i'm actually using 50 for you know useful purpose and i'm not wasting my 25s exactly sure i could you can't split through at 50 billion 25 bills yeah but but i also have the i think i also have the problem that like uh i should be spending my money so this should do this and like this should be this and this well wait yeah i think this should be this and i yeah i can kill the locks and i don't actually need this yeah i think this i don't i'm i'm not i'm not a huge fan of like how verbose it is like if i had to deal with arbitrary um like arbitrary numbers i would have to actually like think of some generic version of this uh yeah you are in an interview right yeah yeah and you already made like three hours exercises two challenges and a lot of questions so it's it's really really nice uh yeah that that's perfect um well sadly that that was all the challenges i have for you i i wasn't expecting you to i we will back to your view here i wasn't expecting you to make the file list i i was expecting that you made that fast but not so fast and same thing with the other ones and that's good for you because you are in an interview and you want to get hired because you want to leave the other shop that it's really boring but uh i wasn't expecting that and it was awesome yeah yeah i mean it's not it's not the first time that i make a tree out of something like we actually have an example in the in the new documentation where there's like a tree of continents and countries and cities and stuff so i wrote like code exactly like this pretty recently and it's also like i think it is i think it is collapsible if i'm not i'm not sure but yeah that's that's the thing i wrote before so it's just familiar well i leaving the interview mode i was about to make you do the exact same um free component from the keynote video and i wasn't sure about if it was a really good example uh and so i said okay let's go for an easier one and i i decided to do the files what do you think you think you were able to do that if you were on this interview like the same this image like the one that it's on public keynote png uh hmm it was way difficult i think yeah i think that i think that should be doable uh i mean it's not like the css is probably going to be ugly because i don't know what's the right way to do it but i think that i would expect that to be doable yeah well i decided to go for the valleys because it's easier and the main thing it was like the the curved lines uh it was really hard but okay uh it was awesome hey there there's a lot of people in the chat that it's saying a lot of things like i can't believe that he made it like how he made it in five minutes and people loves you like in the community people love you i i you already know that people love you in the community at all but this is our like small or own community and they were really excited as me when you decided to go through this process so first of all i want to thank you for being here i hope you have at least some of the fun i have doing this interview and taking this interview yeah yeah it was really fun i i liked the i like the questions and i appreciated that again like it didn't feel like i needed to know anything specific to solve them they're kind of common sense um i'm still curious if there are like more efficient like especially with the um with the arrows thing like the nested loop is just like make me uncomfortable ah the exercise will be available it has to be some way they call sandbox i shall share this i should share they called sandbox on the chat and the echo sandbox will be available whenever you want so if you want to go back to your interview in some free time uh you can go back to it and also for people that comes to the stream usually people can donate to my content through a app called cafecito but today all donations will go to um a omg called vertebrae that it's uh getting it's um trying to build an internet an internet antenna in in the school number 23 in christian anderson from stan sierra concordia here in argentina so all the donations will help uh kids to get internet taxes in a city that it's not available yet so people you have the link down there if you want to help er sadly it's only for people from argentina because it's used arcade pilot that it's like payment method in here and but they already have 76 percent of the objective so that's really nice and thanks for all the people that already donated and for all the people that subscribed during the interview i will match the amount of subscription that was donated and i will donate to virta rail so we can match what you have donated during the the stream so thanks to everyone for helping these owens too to get their to their objectives um and again a ah we have two sponsors uh from for the stream that it's workana and talently all the money that we get from the sponsor it's distributed for for the people in the community we don't get any money from them so we have like a bunch of giveaways that we will do after saying goodbye to them but i can't really thank you enough for being here because it was awesome for me and it was like really a dream from a lot of time we have a game we have cassie we have you this is the first english stream i had in my life so i'm really happy about it uh again then thanks a lot for for the interview and if you want to change your candies for have you ever tried mate from argentina um do you like i don't think so i don't like mother in general so mate in general like have you tried mate yeah i just don't like yeah i don't like it it's okay uh well if you want to change your candies for any other healthy snacks we can get over it ah that's fine thanks thanks to you then and well hope to talk to you again soon all right thank you see you next time bye bye
Info
Channel: Gonzalo Pozzo
Views: 1,104
Rating: 4.8987341 out of 5
Keywords: algorithms, challenge, dan abramov, frontend, interview, react, twitch, web
Id: -w-P4u0x8ig
Channel Id: undefined
Length: 82min 11sec (4931 seconds)
Published: Tue Dec 07 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.