May 30, 2022

FAANG Level Mock Software Engineer Interview (JavaScript)


I hosted a 3rd and final mock interview with this series of FAANG-level coding challenges. Daniel, the interviewer, has almost 20 years of experience as an engineer between Microsoft and Facebook. We found a brave soul to be the interviewee and he actually got to the final challenge in this interview. If you want to see what the coding challenge of a FAANG level software engineer interview looks like, this episode is for you. Enjoy!

This episode is sponsored by Formation.dev
Website: https://fm.dev/DTD
Youtube channel: https://fm.dev/DTDYT

Daniel Tomko (guest):
Linkedin - https://www.linkedin.com/in/danieltomko

Brian Do (guest):
Linkedin - https://www.linkedin.com/in/brianhhdo

---------------------------------------------------

🤝  Join our junior friendly developer community:
https://discord.gg/H69QqZ8MVJ

🔥  Want more personalized help from me? Here are the paid mentorship and review services I offer:
https://calendly.com/donthedeveloper

❤️  If you find my content helpful, please consider supporting me by becoming a channel member and get access to additional perks. Every little contribution helps and is actually used to pay my bills.
https://www.patreon.com/donthedeveloper

---------------------------------------------------

Disclosure: Some of the links below are affiliate links. This means that, at zero cost to you, I will earn an affiliate commission if you click through the link and finalize a purchase.

📚  Web development books and other products I recommend:
https://www.amazon.com/shop/donthedeveloper

Transcript

Don Hansen:

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 f'ing level mock interview. And he did before we started 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 f'ing 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 Mehta, 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 f'ing level hiring. On average formation.dev fellows increase their total compensation by over 80 K. 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 interview. 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, was what we were looking for. Um, and as far as I know, uh, Brian, who's the candidate for this. He actually was not aware of the problem whatsoever. So does this fresh for him? All right. Let's jump into this. Enjoy.

Daniel Tomko:

All right. Well, Brian, nice to meet you. Thanks for taking the time to talk to us this morning. Uh, taking the time out of your busy schedule to, to work on some problems. I hope this is fun. Uh, I always have fun with these problems. I hope you do too. A little bit more about me, just so 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 now working, uh, at formation labs, uh, as an instruction engineer. So teaching software engineers, it's been a lot of fun. Um, yeah. Uh, do you wanna say a little bit about who you are, where, where you come from and then we'll dive into some code?

Brian Do:

Sure. Yeah. Nice and easy Daniel. Um, so I'm a software engineer, mostly with react, but, uh, just finding in general, um, I've had an internship I'm currently at that information. Um, and yeah, so looking for my first time full-time job. So I'm having to interview with you today.

Daniel Tomko:

Yeah. Awesome. Um, So I, I'm going to send you a coder pad link. We'll open that up. Uh, there's a problem already in there. I have arbitrarily picked JavaScripts. Um, if you want to choose something else, you're welcome to switch the language. I don't, I don't actually care what language we do, the sense of 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 code or pad works, uh, feel free to, to ask, uh, 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 code or also, or need any pointers there.

Brian Do:

Yeah, it was good to me. I do a code in JavaScript, so this

Daniel Tomko:

is good. Okay, great. Yeah, give it a read and then, uh, please ask any questions.

Brian Do:

Okay. Yeah. okay. So I'm an attorney in point valley, impossible for word. Um, just to understand and correctly, one sec, there's only one possible, um, value for this. So you'll see which hasn't definitely value a, which is a definite value to

Daniel Tomko:

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. But the second it puts a little different, right?

Brian Do:

So this one you're missing C and the tiles. Um, so you can only score up a and you can score T

Daniel Tomko:

right. Um, and then you'll use the, you'll use the, um, the underscore to stand in for the sea. So you can still make the word, you just can't score all the points.

Brian Do:

Um, so is each tile reusable? Like if I had CDAT

Daniel Tomko:

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, uh, you can't make aardvark.

Brian Do:

Um, and so will I ever be given like, uh, duplicate files then? So like two days, for example. Yeah.

Daniel Tomko:

You could be given two ways.

Brian Do:

Okay.

Daniel Tomko:

Yeah. Um, I mean, it, 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 and that many words you can make with that, um, we're not actually gonna worry about the limits, uh, and the, the maximum number of say A's or teas or whatever you can have. We'll just say like, Hey, this is what you actually have. And can you make these words?

Brian Do:

So it's at first kind of looking at, um, non charity, but just as even, I guess, um, I would want to know which letters and in my word, I can actually sum up. And since we do that, I can look at my tiles, um, since I can have like two ways to know, but, um, yeah, like if I had I could sum up a but only one a, so it's also important for me to note a frequency of tiles, essentially.

Daniel Tomko:

Yeah. The frequency of letters or yeah. Frequency of tiles.

Brian Do:

Right. And, and then, uh, so once I know the balance of frequency of calls, um, I can basically just run through my word in some that, um,

Daniel Tomko:

yeah. If you have the tiles available,

Brian Do:

right. Okay. And let me think real quick. So the underscore is the only thing that might be a little weird, um, okay. To under scrubs in some points how they can stand for any letter.

Daniel Tomko:

And so just like any other character. So let's yeah, like once you've used it, because you don't say didn't have a C, now you can't use it again, but you may, you might have two underscores, right? Just like you might have two A's or two Ts or whatever, you might have two underscores

Brian Do:

we'll ever get a word and where I actually don't have enough house to make

Daniel Tomko:

it. Oh yeah. Good question. Sure. In that case, a score is zero. You can't make the word.

Brian Do:

So I think, um, you know, looking at the frequency of towels is pretty straightforward. I can just make them for your consume half 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 maybe frequency. Then, so for each letter in my word, then, um, if it's, uh, in, uh, my available trials and just subtract out and add whatever the title IX value is to my score. Okay. And otherwise, um, I'm going to need an underscore. So let's say there's a case where I do have an, a scores remaining and zones. Um, and I say under the not Romanians easier.

Daniel Tomko:

Yeah, you're done,

Brian Do:

right? Yeah. Uh, if I do have underscores a lot, then I'll just subtract one from the underscore and move on. Um, yeah, I guess that's it. Huh?

Daniel Tomko:

Yeah. I like it. I'm going to give you one thing. Um, cause this is an interview and I don't want you to have to do busy work.

Brian Do:

You

Daniel Tomko:

don't have to type that.

Brian Do:

Actually. What's really nice though. The way you put it online, six, I could have just copied and pasted this and brackets. I

Daniel Tomko:

still have to add quotes. Oh, I formatted it that way for easy reading, but yeah, that's not how we should spend time in the interview. Right. I was, when you said you do this in Java script and not Python because I don't have the Python version handy.

Brian Do:

So, um, if I, if I do something like this method, I can ask you to try to think about that time space complexity real quick. Sure. Over time first, uh, let's say, let's say tiles is, um, like the length of it and where it is. And, um, and so for first to make a frequency map of the tile, so are we there 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. 300 over the word, reiterate over the tiles, um, and probably space we're actually just keeping track of, um, and files essentially. Right. So we can just say this is all of them.

Daniel Tomko:

Yeah. Yep. I agree.

Brian Do:

So let's call this function, um, uh, create a

Daniel Tomko:

score word, score where it sounds good.

Brian Do:

Um, so we're given a word in tiles, um, and so something we're going to be, uh, incrementing along the way as counts. So let's give it a drag event. We recommend suitor code.

Daniel Tomko:

What is the count going to be again?

Brian Do:

I guess a score. Let me just call it a square. Okay.

Daniel Tomko:

So that'll be your accumulator. Where you, where you'll total up the score.

Brian Do:

Yeah. Okay. I'm with you. So whenever I make your frequency map, I like to kind of abstract it outside. I think it just may say cleaner, so let's make our frequency that cross. Um, so good. Um, um, so for each letter, let's just, uh, put it in our, uh, map objects for class a and then increment it by one. So we'll say fancy syntax and, um, it just means if it's undefined, if it's knowledge, um, then when they realize it's a zero, then we're going to add one to it. Okay. So we'll say, um, uh, I dunno, titled nap. I think that's, uh, an appropriate name.

Daniel Tomko:

Tell counts. Yeah, I like it.

Brian Do:

It's just a new frequency map files, and look you even through my pseudocode. So we have the frequency map. Um, so now we go through your word, uh, and then we'll just do our iteration logic. So for cons, um, so for each quarter two,

Daniel Tomko:

I always have, uh, versus, and

Brian Do:

I made enough mistakes that I rarely make them say anymore. Cause it was very painful, like that's

Daniel Tomko:

painful stage. So

Brian Do:

if, um, I'm

Daniel Tomko:

not pressing this letter,

Brian Do:

uh, actually let me just make this explicit. Yeah. So if it's, uh, in our map and, um, it's value is greater than zero, that means we have talents coming for it. So if that's subtract tile and added to score, so I'll just say tile map butter and that's minus score, proxy goals, um, butter values, whatever, um, Amir spirit. Yeah. Um, okay. So otherwise, if they're under scores remaining, we can subject that and move on and otherwise your returns are okay. So pals, um, those are all still live, uh, Wait, are you switching to Python on me? No, I know. I am. I've never been remembered. Lots of them. I've done that. That's weird. Um, okay. So if, uh, this is in I'll note, then we'll just subtract one.

Daniel Tomko:

Yeah. We can have consumed an underscore, uh, and

Brian Do:

otherwise,

Daniel Tomko:

yeah, no, no, nothing to add to score.

Brian Do:

We're going to switch over here. Would you return this car? So just doing a quick run through, I basically just told him, I said, you're gonna have to work increment with keeping track of score. Okay. The difference, the 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, Uh, add the score otherwise, um, we need to check if there is an underscore, you can use it, so just attract it. And if there's no underscore we can use, then the warrant is a Nazi constructable. So what turns

Daniel Tomko:

arrow? Yeah, we didn't have a letter. We didn't have an underscore. No luck. Yeah.

Brian Do:

Um, so I can try to start testing this out. Yeah. Let's run a few

Daniel Tomko:

tests.

Brian Do:

So let's see. Um, you provided me with two. I think those are a nice point.

Daniel Tomko:

Yeah. We'll start

Brian Do:

there and to NOCCA, um, and the expected value here is five. So if we have chats again, and this time for our tiles, we have to Noah under car. And, uh, so thinking about some cases, um, dementia. So let's think of one where we just cannot construct a word. Sure. I'm just gonna take out this underscore. Yup. Is there, um, let's see. Maybe one more. That's kind of interesting. I'd say this. One's just a habit case, uh, this, where we use an underscore. This one, we can even start the word. Uh, I don't know. Maybe when we're using only underscores. Cool. Yeah. Oh, nice. Looks like it works.

Daniel Tomko:

Yeah. I like it because usually I have bugs on first dry. Yeah. 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, 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 onto 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.

Brian Do:

There's Okay. So now instead of one word, we have multiple routes, um, and we S a set of tiles. So is this a towel? Snow

Daniel Tomko:

stern? Yeah. A set of tiles is still a string. Um,

Brian Do:

yeah. Okay. Right. Is there any this afternoon? No, of course. Okay. So out of those words, what's the highest score that can be achieved. And with what word then? Um, so the knots, uh, uh, innovative, uh, thought process is you're literally just try every word and, um, we'll just keep track of

Daniel Tomko:

the tire and it looked for the map.

Brian Do:

Pretty much. Yeah. So let's say, um, and, um, yeah, I, I might not find a better tuition than this, but just say ready to do something like breaths it be, um, you'll be essentially the top flex. You have floss except this time. So, uh, okay. So let's say a word, like the longest word is, uh, and titles and words. . Okay.

Daniel Tomko:

I'm going to put these on three different lines to make it easier to read, but yes, I'm with you. Okay.

Brian Do:

So doing something like that, her time would be what we did before, except where it's doing it for every single word now. So it's actually 10 times the last time complexity, uh, which was end plus. Oops. So now it's N times and plus K, and for us, it doesn't look like we'd have to keep track of, um, any other data structures at this point. Um, because yeah, we could just have, yeah, we just have one variable for the longest word and that's it actually? Um, well, no, and their score. Sorry. So this is the word in school, right? So it's constant. Um, so constant space plus while it was last time. So last one was old. And 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? Yeah. Hmm. Um, I think I'd have to go through every single water godless, but I wonder if like, I don't have to do the same operation and everyone, um, maybe, um, I'm not really sure yet, but if I just

Daniel Tomko:

have no, 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.

Brian Do:

Um, I don't know, let's say, um, okay, so we can talk, but. Um, grant this point. I'm really just trying to see if I can, um, yeah. Skip logic on. And so for like, could I know if I saw dogs that it's not valid because dog was invalid.

Daniel Tomko:

Oh, I see what you're saying, where you like, you're, you're sort of short-circuiting in some way.

Brian Do:

Yeah. Um, actually I don't see how this would improve its own complexity at all. I should probably look for something else. Um, cause even if I could skip some words,

Daniel Tomko:

like, right, you still would have had to process those words in order to have them arranged in a way that you would notice skip them,

Brian Do:

right? Yeah. You, yeah,

Daniel Tomko:

that's a, that's a good observation. So, uh, there, 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 a part of the higher, no higher. 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 was 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

Brian Do:

that,

Daniel Tomko:

that list of valid words changes rarely.

Brian Do:

Uh, so I have cards in my hand, and then there's a list of

Daniel Tomko:

words. You have titles in your head and the tiles and 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 the 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. Right. 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 attorney 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?

Brian Do:

It's the fact that we're going to be stuck. Um, So, okay. So some tiles, this is static, there's no changes.

Daniel Tomko:

Um, um,

Brian Do:

never changes. Um, but so, I mean, I, so my towels never changed either. I'm not seeing the relevancy analogy yet. No,

Daniel Tomko:

no. 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 the, and then the function only takes the tiles.

Brian Do:

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 sip, subsequence, subsequent

Daniel Tomko:

iteration, programming problem, no sub sequences.

Brian Do:

Okay, so, but that's a later, um, okay. I'll just have to keep track of tiles and I can, can show to him, um, my logic potentially. Um, 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 optimize for just a thousand additional, I don't know why don't you call us what data structure would help me? Um, so before, I mean, my issue was . So the data structure will hopefully be centered on down into that. Um, yeah. I mean, a truck is driving.

Daniel Tomko:

Oh yeah. Yeah. So I either you don't have to run through the whole list or your, or buy because you are arranging it in some way or you can build it into a data structure that then optimizes your query type.

Brian Do:

Um, okay. Uh, okay. So if I'm given some tiles like T Mac, how can I rearrange this? Uh, so I don't need to know the order of

Daniel Tomko:

let's pause for a sec. 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.

Brian Do:

Right. Um, so I was just thinking like, I mean, I was, I was trying to kind of think to that. Um, but by playing with this, with, uh, just the way to your hair, 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 letters in frequency probably. Um, and that will tell me if I can make a towels. Maybe a different tiles are not, um, maybe, uh, one thing that could be relevant is the, I don't know, a max possible score associated with the word.

Daniel Tomko:

Oh, interesting. Okay. So how would you use that?

Brian Do:

Well, So if I know the max possible score could word,

Daniel Tomko:

I'm assuming you had the tiles to make it like what's what, what would be the score,

Brian Do:

right? Hmm. Okay. Great. Possible. Um, okay. What would I do with it? 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 or can there be needed partly only, well, I mean, I'll give you, it can be made either, but like, um, is it going to be made with all the letters or just with underscores, for example. Okay. Okay.

Daniel Tomko:

Like what can, 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

Brian Do:

rights.

Daniel Tomko:

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. So we've got a preprocessing 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?

Brian Do:

Well, this is something we don't need to elsewhere. Um, so we could definitely put this in pre processing, um, for the Astro max top. So we actually do need tops for this. Right. Um, so whereas try to play up the S um, I'm just thinking if we, well, if we took any water at random and competed the actual max score, but we could eliminate it from processing all the other words that were either the same score or. Um,

Daniel Tomko:

okay, well, that's, that sounds like something to me, right? Like how are we, or 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

Brian Do:

list? Um, well, uh, if I want to, you know, puts, um, max scores with then, uh, a good option would just be, but then put the words as teas and an object. And then one of the properties is next court, maybe. Um, oh,

Daniel Tomko:

I see. So you'll, precompute the max scores, so that they're just readily available as you, as you walk through your list.

Brian Do:

Right. Um, so let's saying the construction function, I'm kind of just thinking, well, sure. I've got a dog and dogs. I don't know the actual scores for them. Let's say it's a,

Daniel Tomko:

yeah. Catalina was five. Let's see. Do you cheat to pick dog is also five dogs with a pluralist six.

Brian Do:

Um, I mean, I couldn't just order it on joke this, but, um, I'm just thinking. Um, so if, if I have towels now, let's say, I don't know, I'm still committed to still play with it. Right. But I probably don't have to know. Let's just, um, let's just pick a random word from our map there anyway. Um, so we'll pick cats and we'll compute for cat. What's the actual max score. And let's say we can only gets, um, That's right. Let's let's say we pick dogs Ferris, and let's say we could get six dogs, six parts more. Then what we can in intuitively what we know we can do is cut these from our processing. Um, because,

Daniel Tomko:

but what if we could only make dogs using two underscores? What if the, what if you have six is possible, but given our tiles, we can, you have to actually get there.

Brian Do:

Um, so bypass. Well, I meant like we actually didn't have underscores, um, but

Daniel Tomko:

okay. I followed it, right.

Brian Do:

I guess like six and eight. I don't know. Sure. Okay. Then we know we could, um, cut these from,

Daniel Tomko:

and you don't have to consider them, but ha but then how do we arrange things such that we know we can not process those.

Brian Do:

Um, I'm, I'm tempted to think of like a max heap. Um, cause if you pull dogs first from the heap and you saw you could get six, then the next biggest thing

Daniel Tomko:

it's like, 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?

Brian Do:

Uh, you mean like the first word I have taken them and so

Daniel Tomko:

on. Yeah. Like you've, you've got, you know, 10,000 words in your, in your heat, 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,

Brian Do:

uh, in a Mac seat, but I will take literally the one with the most possible score with the most

Daniel Tomko:

possible score. Yeah. What you're effectively doing that as sorting that macho,

Brian Do:

I guess.

Daniel Tomko:

Yeah. You're sorting them by, in, by the, the inverted sword, like max first I possible score.

Brian Do:

Okay. Um, so, but that sounds so exciting. I don't need a heap. I could just sort them like that. Um, yeah. Right. But so assuming that, um,

Daniel Tomko:

yeah, that's effectively what you're doing, right?

Brian Do:

Yeah. I guess so, right. Yeah. Just the built-in JavaScript method. Yeah. Um, so, okay, so let's say I have a sort of , I'm not really sure I'm adding new information. It's boring. Um,

Daniel Tomko:

but new information you're clarifying your thoughts.

Brian Do:

I say, okay. Quick. Yeah. So I could pick that one with the most potential fairs. Um, whatever that potential is, um, So I just, if I put this in a Ray, I'm just, I'm just not really, I mean, I guess I could put these in doubles, 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.

Daniel Tomko:

Yeah. Tell me if you can, if you can make the full value or you can kind of stop there, right. Because you know, everything after that is going to be at most of the same value because it's sorted. Right. Right. If you could own, if you try to make dogs, but you got five where you might meet, move on because the next thing might have the next word might have a max value of six also, but maybe you can make that one.

Brian Do:

So, okay. I see. So let's play with my kids real quick. So the one I just wrote down is, um, if you know, we, we actually did just find sex. Um, cause we actually said it was possible, then we can skip. 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 say something like border, um, and we'd have to consider this to be on basically. Yeah,

Daniel Tomko:

exactly. Until you, until you're until you find a place where your potential falls off.

Brian Do:

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 all I needed three, however, um, but in a real dataset, I'm sure it's more applicable,

Daniel Tomko:

right. Um, so because you're minimizing. How much you'll have to go through

Brian Do:

to kind of outline the structure. Fred has concert can make in our constructor. We can, um, basically, uh, we're going to make them nap. I got a smile actually. Um, we can just put them in a new array, like temples, like how he said. Sure. So, uh, words in URA has topples where the first thing is word and the second thing is max possible score. Okay. Yup. And then sorts by max and, uh, descending order then, uh, for our let's see. Hi. Yeah. Um,

Daniel Tomko:

XCOR yeah. Max possible score. Highest score. Yeah. Yeah. Sounds good.

Brian Do:

So for that and the bed, um, So we'll start looking from the first word from the first or, um, just, I mean, just from left to right

Daniel Tomko:

base quick, right? Yep. Because we've sorted them already. So now we can

Brian Do:

checks beach, um, highest. Uh, I haven't even before I said possible score, so now I can say like actual score, I guess, um, word and, uh, uh, I think I can copy and paste and stuff. Let's see, where is it? Oh, hi. Is this all I wrote? I guess it is. Yeah. So, um, here we go. So rates and otherwise just keep going to the end. Um, sorry, I don't need to do another, uh, I think I have enough serial code. I can start running it. That's okay. Yeah. Sounds. Sounds good. So let's just, uh, can I just call the solution? Is there. I mean, I know it's kind of lazy. Okay. And so for a constructor, let's take it in the words. Uh, so we'll have a near right on, um, that's about the Holter now. And then, so,

Daniel Tomko:

uh, or is this going to be a class array? A class field.

Brian Do:

Oh, uh, yeah. Good point because I'm going to rephrase your 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 you, you ready? Accept.

Daniel Tomko:

What's that

Brian Do:

yeah. Oh, okay. Nevermind. Then I was just going to say, this is private comes snacks, but if you're at remember, um, okay. So for each word, we're going to put it in there as a topple. And so, uh, let's do that. Let's see. I already wrote a function for this,

Daniel Tomko:

but it takes tiles, right. So let's, let's assume that function exists. We can write it later if we need to. Okay. Yeah.

Brian Do:

Let's um, so let's make a variable. That's just local to this block. Sure. And we'll just score up the word and then we'll put it as a couple and max possible scores. Okay. So for each word, sorry, score should be in here. Okay. Um, we want the Scarpa word suffered each fighter name, say a square plus equals what was it called? A matter guys later values here. Okay. And then, um, since we're done with this, we'll say is the next possible scores principle 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 I was a, B a one. So, okay. At this point, it's sorted. Um, so now we can have our other method. Uh, actually let's call this now possible score. I mean, wait, what do I call them? My last one's called word I mean, I think naming is unironically. One of the hardest things to do in interviews

Daniel Tomko:

in class. Oh, wait in an interview. No, it's just hard all the time. You know, there there's this whole joke about that, you know, there's only two hard problems in computer science, naming things in cash and validation,

Brian Do:

Catherine elevation. Okay. Um, all right. Let me look at my secret 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 squad word. Um, so. Uh, really relying on my pseudocode for this.

Daniel Tomko:

Okay. Yeah, that's checked. Is that a naming thing? Sweet. Is that line 1 38? Is that a word or is that a tool? Yeah. What were we just talking about?

Brian Do:

Okay. Yeah. Max possible score. Um, so, okay then where let's, um, look at the max score we've achieved so far. Uh, we can actually make a zero because something gets loaded in there. Yeah. Um, okay. So for each thing, uh, we check the highest score and then we can update, um, our variable thoughts. I see. Uh, and if our current max score is higher than the, this thing will just be. So if max score is higher than the next possible score here, and let's just get out of here. Yeah. Uh, otherwise, uh, we'll find the actual score of this and some of the, or, I mean, I would compare it with our max okay. Schoolwork. I was just going to keep looking back at what I need it. Yeah, no, it's um, so it's the next itself and, um, the actual, the actual possible value, uh, we can get, uh, it might, uh, it might be cleaner if I bought this in another variable. So like cons actual or

Daniel Tomko:

so to pass the tiles, right mine 1 45.

Brian Do:

Oh yes. Good point. Okay. So we're here. I'll just say actual story. Yeah. Um, and then at the end you can just return X score having,

Daniel Tomko:

how would we want to modify this to return both, both the word and the score. I mean, I did forget to play this word for this score.

Brian Do:

Um, yeah, so it's just a slight modification. Um, but, uh, so basically whenever the max score is here, so I won't do this, um, next, sorry. Actual score inspire, then next score. And I want to update both the next score and the next word. Yeah. Okay, we're returning the word next word. And, uh, my defaults, um, 'cause 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 2001 where the first word is that. Okay. Cause then it would have zero and then everything else is there.

Daniel Tomko:

Uh,

Brian Do:

or I can also make a slight I'm just thinking like, if every single word in the words of right has an actual value of zero, then if this were like actual score would never be greater than zero.

Daniel Tomko:

So you can make no words

Brian Do:

that way. If you were passing around the words. No, no,

Daniel Tomko:

no. What, what if your tile set can make no words?

Brian Do:

Um, that's a good question. What should, where you, um, if we, if there were. Something reasonable to return.

Daniel Tomko:

I'm not sure you have a tile full of Zs or you a tile set full of disease. There are no valid English words. Uh, yeah. W we need to return something. We can just pick something. Uh,

Brian Do:

no, maybe

Daniel Tomko:

yeah. Maybe, or maybe an empty string for max word and a zero. Like you got nothing.

Brian Do:

Okay.

Daniel Tomko:

We can, we can pick something here and that's okay.

Brian Do:

Um, but so let me think. So, um, and, and, and on the other hand, if every single word were possible, but it was just a bunch of underscores, so tiles, then we were, we just returned to any arbitrary

Daniel Tomko:

word, right? Yeah.

Brian Do:

Okay. Yeah. So let me just write that down real quick. Cause I actually, I think I'll have to think about how to accommodate this. If all words possible scoring zero. And, um, you have to know words. Yeah. And her, and, uh, I guess, uh, it looks like you can just do a couple so we can make, um, no. And, uh, should we put there, we're gonna just choose another. Yeah.

Daniel Tomko:

Um, I think zero, like you can't make an, your, you can, you can not do anything to increase your score. You will, this turn, you will do nothing. Um, yeah, I think it 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.

Brian Do:

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 prom even though obviously.

Daniel Tomko:

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 outcome from a, like a higher, no higher perspective, but you, you said something that, uh, I was really hoping you would follow up on. So you, 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?

Brian Do:

Yeah, it wasn't so much as a rejecting it so much as I had never begun to get out of it. I had literally just had the intuition of what if we had tried to use it. Um, but since you had quickly given me, um, uh, hints of going on different direction, I felt that was a lot more safe for me. Okay. Okay.

Daniel Tomko:

Cool. Good. I mean, that's, that's part of my strategy with hinting to is, is that I want to see how you respond when you're in a collaborative environment. Right? Like, so that, that's actually part of the, part of the design of the interview. Um, yeah. That that's not, 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.

Brian Do:

Yeah. I think also I never 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 and you have a better idea that the direction that's.

Daniel Tomko:

Cause I, cause I personally I'm wrong a lot. Yeah. Right. I may have been at this game longer than you, but that doesn't, that doesn't make me, I don't have bad ideas sometimes. Maybe, maybe I shouldn't get thrown out of red herring, but I knew it was a bad idea. Different do.

Brian Do:

Yeah. Well welcome. I was just thinking any interview, like would I really want to view, like, I don't know if I like your hints. That sounds bad.

Daniel Tomko:

Well, you know, you don't know, you don't say it like that. You just 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 make us a non-judgemental statement about an idea. And like, I mean, that's how, that's how engineering collaboration works. Like I throw out 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

Brian Do:

I'll keep that. I'll keep that in mind though. I've never considered actually like coaching back, like blindly with a

Daniel Tomko:

that's. Interesting. Yeah, no, it's, it's, it's definitely something like, to me, that's part of. Being an engineer on a team is having these conversations and having these like debates, you know, when, when we're going through this ideation 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 you artist. Right. So thinking critically about everything that comes in, I think is a good thing.

Brian Do:

Sorry, can we start sharing my screen mode? Oh yeah. Yeah.

Daniel Tomko:

You can, you can start sharing.

Brian Do:

Yeah. Okay, nice. Now I can see your face. And I was like, just doing it on my screen those times. I didn't want to like,

Daniel Tomko:

oh yeah. Well, we tend to avoid infinite loops and interviews, so 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 it did like you very quickly, um, latched onto the idea of, you know, building the map of tiles and then decrementing as you accumulate the score. Um, I really liked how you separated the problem solving part of the process from the actual coding part and made the coding go really, really smoothly and easily. Um, 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 era of like, and versus ampersand 10%. Right. But those things, 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, I'll play compiler. Right. That's really 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. Um, and then the second part gets, uh, 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 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 to 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. Um, that all went, went really smoothly. Well, not

Brian Do:

second car. I thought there were two real interesting things. Like one is, I mean, it is that I was taking notes on how scrambled, what was played like while you were telling me. And the other one was, um, when I, when I talked about my brute forests, um, so I made a time for everything and I wasn't even considering about the other band. Cause I was like, the time actually doesn't even improve. What's

Daniel Tomko:

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 and 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 end 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,

Brian Do:

but, um, it's also interesting cause this, this is a class problems. That's just kind of like business logic then. Cause I mean, I don't know. Maybe you would burn like, even though the time flex you have those same, you would agree. Like the thing we did later on was more efficient even though

Daniel Tomko:

yeah, it's, it's a little bit more efficient. Um, it's not more efficient from a, from a, 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 is going to be like in this case, it's not a, lexicographical sort of the words, it's a descending sword 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.

Brian Do:

Um, that's definitely, um, a class of problems. Doing a lot of Linkerd doesn't necessarily like I'm not inclined to think about, um, cause I'm literally only talking about time flexibility, but, um,

Daniel Tomko:

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 Lee 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 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? Cause like this kind of problem comes up all the time. You've got a bunch of data you need to munge it around and organize it in a way such that you can answer. And then, or a class of questions, like, that's like, just like you said, it that'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. Like class of problems, that's likely to come up every day on the job. So this kind of interview question, but yeah, lead code does not prepare you for it.

Don Hansen:

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 watch this on YouTube, let me know what you thought in the comments. And again, seriously, thanks so much for sponsoring this video. Formation. Definitely check them out, but I hope this helps. Good luck.