FAANG Level Mock Software Engineer Interview (JavaScript)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back to don the developer podcast where we help aspiring web developers get jobs and junior developers grow in this episode we brought back a third person to try to attempt to get to the second problem of this thing level mock interview and he did before we start this video i just want to say thanks so much to formation.dev for sponsoring this video if you are a junior to mid-level engineer who wants to land a job at a fang level company their engineering fellowship is made for you formation.dev is a fellowship program where their mission is to help software engineers from non-traditional backgrounds break into top-tier companies such as google meta and microsoft formation.dev has undisputedly the top team of engineers from facebook and next door who interviewed thousands of candidates and trained hundreds of interviewers during their tenure this insight is how formation created a better and more effective way to prepare engineers for the fang level hiring bar on average formation.dev fellows increase their total compensation by over 80k after completing the fellowship you can apply for free on their website formation.dev and whether or not you are accepted into the program you will get invaluable career advice from their assessment and a free prep guide that's a really helpful resource for your fang level interviews also check out their youtube channel for technical interview tips and interviews with formation.dev mentors all right i know you're probably ready to get into this so the interviewer daniel he's actually head of instruction at formation he was an engineer at facebook and microsoft for almost 20 years where he conducted hundreds of interviews and even created training materials for the interviewers i think he's perfect for this and i actually asked daniel to help me find someone that would find the first problem to be pretty easy but would find the second problem to be a little bit more challenging and so daniel actually found a fellow at formation who's a perfect skill level with what we were looking for and as far as i know brian who's the candidate for this he actually was not aware of the problem whatsoever so this is fresh for him all right let's jump into this enjoy all right well brian nice to meet you thanks for taking the time to to talk to us this morning uh to taking time out of your busy schedule to work on some problems i hope this is fun i i always have fun with these problems i hope you do too a little bit more about me just you know who you're talking to you can ask kind of more intelligent questions i've been a software engineer at microsoft for 11 years and then facebook for eight i'm now working uh at formation labs uh as an instruction engineer so teaching software engineers it's been a lot of fun um yeah do you want to say a little bit about who you are where you come from and and then we'll dive into some code sure yeah nice to meet you daniel um so i'm a software engineer i was here to react but uh just find it in general um i've had an internship i'm currently at all information um and yeah looking for my first time full-time job so i'm happy to interview with you today yeah awesome um so i i'm gonna send you a coderpad link we'll open that up uh there's a problem already in there i have arbitrarily picked javascript um if you want to choose something else you're welcome to switch the language i don't actually care what language we do this ends whatever you're most comfortable with do feel free to change it and i'll roll with that uh if you need anything um if you need any like tutorial about how coderpad works uh feel free to ask i know all these tools function a little bit differently so um just just let me know if you need a moment to play with the coderpad also or need any pointers there yeah it looks good to me i do code in javascript so this is good okay great yeah give it a read and then please ask any questions thank you [Music] okay so i'm determining a point value possible for the word um just to understand it correctly it looks like there's only one possible um value for this so you see which has a definite value a which is a different value in t right and so in that case it's just the sum of those values that those are the points you can score given that input yeah yeah the second place is a little different right so this one you're missing c in the tiles um so you can only score up a and you can score t right um right and you'll use the you'll use the um the underscore to stand in for the c so you can still make the word you just can't score all the points i see um so is each tile reusable like if i had umit yeah good question no so each tile is a consumable so you can use it once and then it's gone so if the word is aardvark and you need two a's but you only have one you can't make aardvark um and so will i ever be getting like uh duplicate alice then so like two a's for example yeah you could be given two ways yeah i mean if this if you've ever played scrabble this is actually the point values are actually exactly scrabble um and i forget how many a's are in the game but you could potentially have a full tray of a's not many words you can make with that um we're not actually going to worry about the limits uh and the the maximum number of say a's or t's or whatever you can have we'll just say like hey this is what you actually have and can you make these words okay so to first kind of look at it um non-cody but just as ximena goes i would want to know which letters in my word i can actually sum up and so to do that i can look at my tiles um since i can have like two a's and i want to know that um you know like if i had this c-a-a-t i could sum up a but only one a so it's also important for me to know the frequency of tiles essentially in your yeah the frequency of letters or yeah frequency of tiles right okay and then uh so once i know the palette the frequency of kyle's um i can basically just run through my word and sum that up um yeah if you have the tiles available right mm-hmm okay and let me think real quick so the underscore is the only thing that might be a little weird um okay the underscore represents a point how i can stand for any letter and it's just like any other character so let's yeah like once you've used it because you you know say didn't have a c now you can't use it again but you may but you might have you have two underscores right just like you might have two a's or two t's or whatever you might have two underscores will ever get a word where i actually don't have enough styles to make it oh yeah good question sure in that case uh score is zero you can't make the word okay yeah [Music] so i think um you know looking at the frequency of tiles is pretty straightforward i can just make a frequency map of it um so going to words it's also pretty straightforward if you know a letter is in tiles um let me write some of this down sure so let's say make frequency map the titles then so for each letter in my word then um if it's uh in uh my available tiles then just subtract that and add whatever the title's value is into my score and otherwise i'm going to need an underscore so let's say there's a case where i do have underscores remaining and i don't um and actually the not remaining is easier yeah but uh if i do have underscores left then i'll just subtract one from the underscore and move on um yeah i guess that's it huh yeah i like it i'm gonna give you one thing um because this is an interview and i don't want you to have to do busy work i'll give you you don't have to type that actually what's really nice though the way you put it on line six i could have just copied and pasted this and um brackets i still have to add the quotes the oh i i formatted it that way for easy reading but yeah that's not how we should spend time in the interview right i was very thankful when you said you do this in javascript and not python because i don't have the python version handy so um if i if i do something like this method i can actually try to think about the time space complexity real quick sure super time first uh let's say let's say tiles is n like the length of it and word length is n um and so first we make a frequency map of the tile so we do an oven operation um and then we'll go through every single letter of each word so that's and what's oh right um yeah yeah okay we go over every single letter of that one word um so this is actually n plus n so we iterate over the word varied over the tiles um yeah and for our space we're actually just keeping track of um the tiles essentially right so we can just say this is of them yeah yep okay i agree so let's call this function um uh create uh score word square word sounds good um so we're given a word entitles um and so something we're going to be uh implementing along the way is counts so let's keep track of that back in my pseudocode what is what is the count going to be again i guess the score let me just call the square okay that so that'll be your accumulator variable where you'll total up the score yeah okay i'm with you so whenever i make a frequency map i like to kind of abstract it outside i think it just makes it cleaner so let's make a frequency map class um so given um it's a string any iterable um so for each letter let's just uh put it in our map objects for class and then increment it by one so we'll say fancy syntax um just means that it's undefined if it's knowledge um then we'll initialize it to zero and then we'll just add one to it okay so we'll say um i don't know tile map i think that's uh inappropriate yeah tile map tile counts yeah i like it so it's just a new frequency map of files okay looking through my pseudocode so we have the frequency map um so now we go through word uh and then we'll just do our iteration logic so for cons um right so for each letter let's see i always have something hard about uh versus in i made enough mistakes that i rarely make mistake anymore because it's very painful like that's 20 times letter uh actually let me just make this explicit yeah so if it's uh in our map and um its value is greater than zero that means we have tiles remaining for it so if that's uh subtract tile and add it to score so we'll just say tilemap letter minus minus and score plus equals better values of letter um yeah okay so otherwise if there are underscores remaining we can subtract that and move on and otherwise we'll return zero okay so else um i guess i'm just saying like this else if wait are you switching to python on me no oh well i know i am i've never i remember the last time i've done that that's weird um okay so if uh this is in taoman then we'll just subtract one yeah we've now consumed an underscore uh and otherwise yeah no no nothing to add to score i'll just return zero and over here grouping returns score so just doing a quick run through uh i basically just followed my certificate but yeah increment we're keeping track of score okay later frequency map of the tiles going through each letter uh if it's in our map then we'll just subtract one from our map uh and add the score otherwise um we need to check if there's an underscore we can use xo just subtract it and if there's no underscore we can use then the word is uh not constructable so we'll return zero yeah we didn't have a letter we didn't have an underscore no luck yeah um so i can try to start testing this out yeah let's write a few tests so let's see um you provided me with two i think those are a nice second point yeah we'll start there and tanoka um and the expected value here is number five so if we have cats again and this time for our titles we have to noah underscore and it is so thinking about some cases um cement cases so let's think of one where we just cannot construct the word sure so i'm just going to take out this underscore yep it's here um let's see maybe one more that's kind of interesting i'd say this one's just a happy case um this one we use in underscore this one we can't even construct the word but i don't know maybe one we're using only underscores cool yeah let's get this around yeah oh nice looks like it works yeah i like it because usually i have bugs so first try yeah well we we caught the whole python versus javascript yeah no of course uh yeah but that wasn't a logic bug you you knew exactly what you were doing there uh and that well this is this is what happens you know in in these modern systems where we're all looking at a bunch of different languages every day right like that's a normal that's a normal kind of mistake uh so yeah cool awesome all right let's uh let's jump on to the to the next uh the next part of this okay excellent um okay i'm gonna uh yeah i'll just paste this at the bottom now all right there's okay so now instead of one word we have multiple words um and we a set of tiles so it's just a tile's still a string a tile yeah set of tiles is still a string um yeah okay right i'm just writing this down yeah no of course okay so out of those words what's the high score that can be achieved and with what word okay um so the knots uh in the innovative uh thought process is to literally just try every word and uh we'll just keep track of the sorry and look for the max pretty much yeah so let's say um go through every word and um yeah i i might not find a better solution than this but just to write it down sure so to do something like this it would be um it would be essentially the time complexity of the last one except this time so uh okay so let's say a word like this the longest word is uh uh and let's say tiles is okay and words like the length of it okay um i'm gonna put these on three different lines to make it easier to read but thanks yes i i'm with you okay so doing something like that the time uh would be what we did before except word gets doing for every single word now so it's actually n times the last time complexity uh which was n plus oops so now it's n times n plus k and press base it doesn't look like we'd have to keep track of um any other data structures at this points because yeah we could just have yeah we just have one variable for the longest word then that's it actually um well no and the score sorry so yeah word and score so it's constant um so constant space plus was last time so last one was of m so that was just okay sure um so to think real quick though you know is there a better way than going through every single word um i think i'd have to go through every single word regardless but i wonder if like i don't have to do the same operation on everyone um maybe i'm i'm not really sure yet but if i just said no but i like i like that you're thinking you know throwing some ideas out there and and then trying to like pick holes in them um i don't know let's say we're not um okay so we kind of dog but um at this point i'm really just trying to see if i can um yeah skip logic on some so like yeah could i know if i saw dogs that it's not valid because dog was invalid oh i see what you're saying we're like you're you're sort of short circuiting in some way yeah um actually i don't see how this would improve the time complexity at all i should probably look for something else um because even if i could skip some words like right you still would have had to process those words in order to have them arranged in a way that you would know to skip them right yeah you yeah that's a that's a good observation so uh there's a interesting part of this problem uh which like have you played scrabble i mean a valid answer is no that's not that's not part of the higher no higher criteria okay okay so when when you're playing scrabble you have a set of tiles in front of you on a tray that only you can see and none of the other players can see and you're trying to make words um in the game of scrabble there is a list there is an official list of what words are valid and it's a book it's a big ass like dictionary that serious scrabble players will all have on their shelf and really serious scrabble players will memorize even for the most part uh so that that list of valid words changes rarely so sorry i have cards in my hand oh i know there's a list of words you have tiles in your hand and the tiles in your hand is going to change right so as you play you'll you'll use tiles and you'll draw new ones so you're continually getting a new tray of tiles but that word list certainly over the course of a game is never going to change right i mean it's literally a book or now maybe now it's a website but you know it's you're definitely not going to change the word set in the middle of a game okay right um i play if i play a word and then and then it's your turn now that word's not valid anymore because it got removed from the dictionary between my turn and yours that sounds like a crappy game um yeah so anyway is there something we can do given that the list of words is effectively going to be static so the fact that we're going to be static um so okay so i have some tiles this is static this never changes um hmm never changes um but it's like i mean i so my tiles never change either i'm not seeing the relevancy analogy yet actually no you know your tiles do change effectively this becomes a one parameter function you could you could make this into a class for example where the word list gets passed into the constructor and then and then the function only takes the tiles oh okay so um i can optimize so i don't i just have to think about like if i can set up the words in some way then um on every subsequent subsequence though iteration this is not a good programming problem no subsequences okay so but so later um okay i'll just have to keep track of tiles and i can kind of shorten my logic potentially so i can set up boards and some data structure and then okay so let's see what kind of data structure would so now i'm thinking if i'm trying to you know just optimize for just a thousand um additional i don't know function calls whatever you want to call it what data structure would help me um so before i mean my issue was i'd have to run through the whole word list so the data structure would hopefully be something that i don't do that um yeah i mean the truck keeps trying sorry oh yeah yeah so i either you don't have to run through the whole list or you're worried by because you are arranging it in some way or you can build it into a data structure that then optimizes your query time let's see um okay uh okay so if i'm given uh some tiles like t-mac how can i rearrange this uh so i don't need to know the order of the letters in each word so when you're given the tiles you probably don't want to rearrange the words at that point you probably are going to want to pre-process the words and then just have them that way and not rearrange them every time right so i was just thinking like i mean i was trying to kind of think to that by playing with this with uh okay just the way through here but um so what i so for each word i don't need to know the order of letters um so whatever data structure it is i just really need to know what i mean like the frequency of letters in it like what letter is in the frequency probably um and that will tell me if i can make it tells i mean make different cells or not um maybe uh one thing that could be relevant is the i don't know max possible score associated with the word oh interesting okay so how would you use that well so if i know the max possible score for word like assuming you had the titles to make it like what's what what would be the score right hmm okay right possible um okay what would i do with it [Music] well i mean if i knew all of them could be made then obviously i'd just take the best one but then you know the issue is which one of them can be made right or some of them can be made partly only well i mean i'll give you can it can be made either but like um is it going to be made with all the letters or just with underscores for example right like what yeah what's the maximum possible score if you had all the letters and then what's the score you can make given the tiles you have right yeah and of course so these are these are two interesting things we can we can compute and when would we want to compute each of them in our in our process right we've got a pre-processing step where we're going to do something with all the words all the valid words and then we have our final hey what's the best i can do with these tiles right now well this is something we don't need tiles for um so we could definitely put this in pre-processing um for the actual max top so we actually do need tiles for this right um so if we try to play with this um i'm just thinking if we well if we took any word at random and computed the actual max score of it we could eliminate from processing all the other words that were either the same score or lower um okay well that's that sounds like something to me right like how are we how are we arranging the words it it how you if we follow the process you just described what does that end up with how how does that arrange our words in our list um well uh if i want to you know put um max scores with them uh a good option would just be put them put the words as keys in an object and then one of the properties is max score maybe um oh i see so you'll pre-compute the max scores so that they're just readily available as you as you walk through your list right um so let's say in the construction function i'm kind of just thinking about sure dogging dogs i don't know the actual scores for them let's say i forgot it's five yeah country was five let's see two d4 pig dog is also five and dogs with a plural is six um [Music] i i mean i could just store it and i'll joke this but um i'm just thinking um so if if i have tiles now let's say i [Music] i don't know i'm still tempted to still play with the array but i probably don't have to know let's just jump um let's just pick a random word from our map because they're in our map anyway um so we'll pick cats and we'll compete for cat what's the actual max score and let's say we can only get um actually let's let's say we pick dogs first and let's say we could get six so pick dogs and six possible then what we can intuitively what we know we can do is cut these from our processing um because well but what if we could only make dogs using two underscores what if the what if you know six is possible but given our tiles we can you have to actually get there um so by possible i meant like we actually didn't have underscores um but whoa okay i followed right i i guess like six of you i don't know sure okay then we know we could um cut these from you don't have to consider them but but then how do we arrange things such that we know we can not process those um i'm i'm tempted to think of like a max heap um because if you pull dogs first from the heap and you saw you could get six then the next biggest thing is that yeah you can right you pull it out you pull something out you try it it either works or it doesn't yeah okay so if you do that what what is the order that you're going to be considering each word uh you mean like the first word i had taken and so on yeah like you've got you know 10 000 words in your in your heap right what's the order which one do you pick up first what's the next one you pick up like what's that ordering uh in a max heap i'll take literally the one with the most possible score with the most possible score yeah so what you're effectively doing then is sorting them aren't you i i guess so yeah yeah you're sorting them by in by the the inverted sword like max first by possible score okay um so but that sounds so uh sorry i don't need a heap i could just sort them like that um yeah right but so assuming that um so yeah yeah that's effectively what you're doing right yeah i guess so or you know just the built-in javascript method yeah um so okay so let's say i have a sorted array then bugs i'm not really sure i'm adding new information at this point um but no you're not getting information you're clarifying your thoughts i see okay quickly yeah so i could pick that one with the most potential first um whatever that potential is uh so i just if i put this in array i'm just i'm just not really i mean i guess i could put these in tuples so let's say dogs and six um yeah and so basically like if i find that i can get six at some points and then the next one is five i can just stop there yeah i mean if you can if you can make the full value you can kind of stop there right because you know everything after that is going to be at most the same value because it's sorted right right if you could only if you try to make dogs but you got five well you might move on because the next thing might the next word might have a max value of six also but maybe you can make that one okay so okay that's it so let's play with that k real quick so the one i just wrote down is um if you know we we actually did just find six um because we actually said it was possible then we could skate however let's say uh we we said we can make dogs but we only got four for this um i don't know i guess we can also have like a max score so far and yeah say something like boy yeah um then we'd have to consider this right and to the end basically exactly until you until you're until you find a place where your potential falls off interesting um so i feel like what's kind of interesting about this is i think the time complexity is actually exactly the same as online 83. however um but in a real data set i'm sure it's more applicable right um so because you're minimizing how much you'll have to go through right so the kind of outline the structure for this class we can make in our constructor we can um basically uh we can make a map i guess well actually um we could just put them in a new array like tuples uh like how i said sure so puts uh words in new array as tuples where the first thing is word and the second thing is max possible score okay yep then sorts by max in a descending order then uh for our uh let's see highest yeah um next score yeah max possible score high score yeah yeah sounds good so for that my bad um [Music] so we'll start looking from the first word uh from the first um just i mean just from left to right basically right yep because we've sorted them already so now we're right check each um highest uh i mean before i said possible score so now i can say like actual score i guess um and then i think i can copy and paste some stuff let's see where is it oh is this all i wrote i guess it is yeah so uh there we go so great yep and otherwise just keep going to the end yeah i'm sorry i don't need to do another uh i think i have enough pseudocode i can start writing it out that's okay yeah yeah sounds sounds good so let's just uh can i just call the solution exactly sure i mean i know it's kind of lazy um okay so for a constructor let's take in uh the words uh so we'll have a new array on um i don't know it's about double turnout and then so uh it's gonna be a local array or is this gonna be a class array uh a class field oh uh yeah good point cause i'm gonna reverse here later um so actually let me define that up here um let's say let's say it's called um uh word max possible scores um okay that makes sense so for wait you're writing javascript probably what's that are you writing javascript by the way yeah oh okay nevermind then i was just gonna say this is private um syntax but if you're right nevermind um okay so for each word we're going to put it in there as a tuple and so uh to do that let's see i already wrote a function for this but it takes tiles right so we need to let's let's assume that function exists we can write it later if we need to okay yeah um so let's make a variable that's just local to this block sure and we'll just scroll up the word and then we'll put it as a double and max possible scores okay so so for each word oh wait sorry score should be in here okay so now um we want to score forward so for each letter name say score plus equals what was it called uh better values better values here okay and then since we're done with this we'll say max possible scores push the tuple of the word and then the score yep so uh then we just want to sort it and then we'll just get out of here yeah oh wait let me say it oh that wasn't bf1 so okay at this point it's sorted um so now we can have our other method uh actually let's call this not possible score i mean uh wait what did i call my last one scoreboard okay yeah max possibly use yes i mean i think naming is unironically one of the hardest things to do in an interview sometimes wait in an interview no it's just hard all the time you know there's this whole joke about that you know there's only two hard problems in computer science naming things and cache and validation caching validation okay um all right let me look at my pseudo code real quick okay so from we'll look at each word and we'll find the highest score each word we've wrote we've written a function for that called square word um so okay uh really relying on my pseudocode for this okay yeah that's checked what is that naming things wait is that line 138 is that a word or is that a tuple yeah what were we just talking about okay yeah max possible score yeah um yeah so okay and then where let's uh look at the max score we've achieved so far uh we can actually make it zero because nothing gets lower than zero yeah um okay so for each thing uh we check the highest score and then we can update um our variable that's i see uh and if our current uh max score is higher than the this thing will just break so if max score is higher than max possible score here then let's just get out of here yeah and uh otherwise uh we'll find the actual score of this and sum it up or i may not compare it with our max okay scoreboard i just have to keep looking back for what i named it yeah so it's the max itself and um the actual possible value we can get uh it might i mean i don't know it might be cleaner if i put this in another variable so like cons actual we also have to pass the tiles right line 145. oh yes good point okay so over here i'll just say actual score yeah um and then at the end you can just return max score yeah how would we do it how would we want to modify this to return both both the word and the score oh yeah i did forget that play this word for this score um yeah so it's just a slight modification yeah um but uh so basically whenever the max score is here so i won't do this um if next oh sorry actual score it's higher than x4 and i want to update both max score and the next word okay we'll return the word uh next word and uh by default um because i mean okay if every single word had a actual possible score of zero then this would be uh maybe i can just default this to one or the first word is that okay because then it would have zero and then everything else was zero uh or i can also make a slight greater than or equal this way once it works i'm just thinking like if every single word in the words array has an actual value of zero then if this were like actual score would never be greater than zero so what if you could make no words but wait if you were passing away in their words no no no what what if your tile set can make no words um that's a good question what should we um if we have no words something reasonable to return there are no valid english words uh yeah yeah we need to return something we can just pick something uh no maybe yeah maybe or maybe an empty string for mac's word and a zero like you got nothing okay we can we can pick something here and that's okay um but so let me think so um and but if and on the other hand if every single word were possible but it was just a bunch of underscores for titles then we would just return any arbitrary word right yeah okay yeah so let me just write that down real quick because actually i think i'll have to think just a bit about how to accommodate this if all words possible with score zero return any word and um we have no words yeah return uh i guess uh it looks like you change this to a couple so we can make um no and uh should we put there are we're going to just just know as well i think yeah um i think zero like you can't make it you're you can you can not do anything to increase your score you will this turn you will do nothing so um yeah i think that makes sense there let's we're actually exactly on time so this is this we got to a really good spot let's let's pause there uh very cool questions comments for me um uh no i thought it was really cool how um you didn't really care that much about the testers i mean you're kind of helping me out with that and uh you were pretty involved in that process it felt like you know we're kind of collaborating on a problem even though obviously you know it yeah right i have i actually have one question for you that i i had um this to be clear this wouldn't have changed the the outcome from like a higher no higher perspective but you you said something that uh i was really hoping you would follow up on so you threw out the idea or you not you mentioned you brought up the idea of using a try and then you didn't go down that path why did you reject that idea you you considered it and then you very quickly moved on what yeah it wasn't so much as rejecting it so much as i had never begun it out of it i literally just had the intuition of what if we had tried to use a try um but since you had quickly given me a hint of going a different direction i felt that was a lot more safe for me okay okay cool good i mean that's that's part of my strategy with hinting too is is that i want to see how you respond when you're you know in a collaborative environment right like so that that's actually part of the part of the design of the interview [Music] yeah that's not in that's not an indication that maybe you're you're not doing well it's an indication of like oh i'm trying to learn how do you do in a collaborative environment where we're both bouncing ideas off of one another yeah i think uh so in a real environment like um if we were both working on problem like none of us knew the answer i would still consider using a try um this is more like collaborating where i guess like you're more senior than me so like i trust that you have a better idea about the direction because i because i personally i'm wrong a lot yeah right i'm i may have been at this game longer than you but that doesn't that doesn't make mean i i don't have bad ideas sometimes maybe maybe i should have thrown out a red herring that i knew was a bad idea do you ever do that yeah oh well i was just thinking like today i was just thinking in an interview like would i really want to be like i don't know if i like your hands like that sounds bad well no you no no you don't say it like that you say it like hey that's an interesting idea but i'm not sure it works because of this this and this like oh if we did that we'd end up having to solve this other problem over here that's maybe not leading us in the right path towards a simpler solution like you can always you know like make us a non-judgmental statement about an idea and like that i mean that's how that's how engineering collaboration works like i throw an idea you throw out an idea we try to like judge the ideas not like hey daniel you're dumb that was a bad i mean i may be dumb but that's not how the conversation i'll keep that i'll keep that in mind though i've never um considered actually like coaching back even like politely with a hints that's interesting yeah no it's it's it's definitely something like to me that's part of like being an engineer on a team is having these conversations and having these like debates you know when we're going through this ideating process to solve a new problem um like yeah in this case i know the problem pretty well um but but in in a real setting you know i haven't when i haven't solved the problem before my idea might be as good as yours or maybe not as good as yours right so thinking critically about everything that comes in i think is a good thing oh sorry can i stop sharing my screen by the way oh yeah yeah yeah you can stop sharing [Music] yeah okay nice now i can see your face i was like just staring at my screen the whole time because i didn't want to like a little loop oh it would be right yeah we tend to avoid infinite loops in interviews so that's that's a good thing awesome any other any other comments questions i mean i think this went really well i i um the way this problem is structured with the two parts um it's intended to be a first part that goes relatively smoothly and easily and and it did like you very quickly um latched on to the idea of you know building the map of tiles and then decrementing as you accumulate the score i really liked how you separated the problem solving part of the process from the actual coding part it made the coding go really really smoothly and easily um and and you were always double checking the code you're writing against the comments you had written previously with with the idea so it it reduced the kinds of logic errors like we still had that silly syntax error of like and versus ampersand ampersand right but those things this the system will tell you about the runtime will tell you like hey there's a syntax error there right you'll get this immediate feedback even if it wasn't from me right like that's why i actually pointed that out was like that was the kind of error that you're going to get rapid feedback about i'd rather just short-circuit it even a little bit more and say hey i'll play compiler right that's really yeah that's pretty cool um but you weren't making logic errors because you had very cleanly and clearly defined exactly what your logic was going to be ahead of time not even in pseudocode in plain english and so then the coding part went went really smoothly and then the second part gets up gets a lot more interesting because there there's these trade-offs around like how do you structure the data there's many data structures you can consider um this this was actually the first time i've run this problem where somebody got to the second question and actually hadn't played scrabble before well yeah which is which is which is fine right like again that's that can't be part of the higher no higher criteria right so if you've played scrabble it's a little bit more clear at the outset that the word list isn't going to change so i needed to like provide that part that context but i don't care because i can't expect everyone to actually know that that's how the game works or or even that this is part of a game right um and then once you once we sort of get to that point like okay the word list isn't going to change now that starts to open up some possibilities for like how we approach the problem uh yeah that all went went really smoothly on that second part i thought there were two really interesting things like one is i mean is that i was taking notes on how scrabble was played like what you were telling me and the other one was um when i when i talked about my brute force um so i made the time collection for everything and i i wasn't even considering about the other thing because i was like time complexity doesn't even improve what's the point what's the point yeah exactly like you're making engineering trade-offs like that's that's awesome right like hey actually this is not bad this isn't a quadratic algorithm for example right like it was basically linear in the size of the input like yes you're doing some multiplication there but at the end of the day the sum total of the input the real n in our complexity analysis is always this the size the total size of the input so like you were you know your complexity was was well-bounded already um but um it's also interesting because this this is a class of problems that tests that kind of like business logic thing because i mean i don't know maybe you would but like even though the time collector was the same you would agree like the thing we did later on was more efficient even though it's underwater yeah it's it's a little bit more efficient um it's not more efficient from a from like a complexity analysis perspective but it's always a good idea to organize data in a way that allows you to easily answer the questions at hand right even if it's not making a dramatic difference in the theoretical you know average case or worst case runtime complexity you're still making your task easier and the fact that we were able to make the task easier with not a lot of code and in fact just calling a built-in sort function you know and and being intentional about the direction we're sorting and what our sorting criteria you know is going to be like in this case it's not a lexicographical sort of the words it's a descending sort based on the total max score like so we made an explicit decision there that made the rest of the process easier so it's not an optimization per se but it's a simplification i think that's definitely a class of problems that doing a lot of leak code doesn't necessarily like i'm not inclined to think about um because i'm literally only thinking about time complexity but um well and i'm glad you mentioned that because i think that's i think that's one of the shortcomings with number one practicing lead code problems because they don't actually prepare you to do good engineering right they prepare you for questions that people tend to ask in interviews but they don't prepare you for making engineering trade-offs and you know and unfortunately i people do actually use that style of question in a lot of interviews and i think it's questionable the kind of signal that they're getting in order to hire somebody as an engineer right because like this kind of problem comes up all the time you've got a bunch of data you need to munch it around and organize it in a way such that you can answer a question and you know or a class of questions like that's like just like you said it's like business logic and that's as in most product engineering roles like that's most of the work is this kind of thing so to me this kind of question is highly applicable to to uh to the interview process right because it it shows me what you're going to do on a problem on a class of problems that's likely to come up every day on the job so i'm this kind of interview question but yeah lead code does not prepare you for it all right it is raining heavily uh the storm just flew in just as i was about to record this final outro so you might hear it in the background but let me know what you thought if you watched this on youtube uh let me know what you thought in the comments and again seriously thanks so much for sponsoring this video formation um definitely check them out but i hope this helps good luck [Music] just see everything
Info
Channel: DonTheDeveloper
Views: 36,812
Rating: undefined out of 5
Keywords: faang software engineer interview, faang software engineer, faang interview preparation, faang interview questions, faang preparation, fang software engineer interview, faang, facebook software engineer interview, google software engineer interview, amazon software engineer interview, apple software engineer interview, netflix software engineer interview, web development podcast, donthedeveloper podcast, donthedeveloper, don the developer
Id: 4W-q6nvh3bs
Channel Id: undefined
Length: 60min 5sec (3605 seconds)
Published: Mon May 30 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.