Placeholder Image

字幕表 動画を再生する

  • Hey, everyone, my name is y que on I'm a former software developer, Google.

  • In this video, I'm going to walk you through the process I would personally use to get through an actual quoting, intimate question from Google Here.

  • I'm going to use a question from Google as an example, but you be able to use the same process to get through programming interviews with any company, and I chose a relatively simple problem here so that I can explain the whole process quickly.

  • Now here's the problem.

  • You're given an array of editors for example, 13 to 4, which represents a number.

  • This array of represents 1000 324 and the problem is writing a function that takes disarray on as one to this number.

  • So your function, if you're given this array, should return 13 to 5, which represents 1325.

  • Now, how would I solve this problem?

  • Let me walk you through the whole process I would personally use to solve this problem step by step.

  • Step one.

  • Start with clarifying questions on ah, high level discussion, One of the clarifying questions you could have asked here is.

  • Could this already be empty on?

  • The interviewer might say No, it cannot be empty.

  • You could also ask, Can we always assume that each element off this array is always an injured or between zero and nine?

  • And let's say it is indeed the case.

  • So each element of this array is always an intruder between there on nine, and you might ask a few more questions to clarify all of the assumptions you have.

  • Once you feel like you have enough information to start solving this problem, you should start with, Ah, high level discussion in this stays.

  • Just explain the ideas you have in concept first without using too much code.

  • And it's important not to start quoting right away, especially for more complex problem, so that you don't waste time writing code on a solution that doesn't work in the end.

  • For example, for this problem, you might say something like, Well, this problem would be easy.

  • If the given array ends with a number that's not nine, for example, four This array 13 to 4 because in that case we can just add one to the last item and we get five and then copy over everything else if the last integer is nine.

  • So if we had, for example, 13 to 9 instead off 13 to 4, then would need to change this number 20 and then carry one to the next number on keep repeating this process until we have nothing to carry.

  • At that point, we can copy over everything else and we're done.

  • The only tricky case for this problem is when we have something like my 199 or 999 in the Given array, because then the new array will need to be 1000 So from our function will need to create a new array with a different length length four here and then returned this Nuri for this problem.

  • Or maybe if the problem is more complex, I'd recommend that you list out a few potential approaches you could use to solve this problem.

  • For example, for this particular problem, you might say, Well, I'm thinking about using either an iterative approach with a four loop or with a recursive approach, ways rickerson, especially for more complex problem.

  • It's really important to list out a few potential solutions you have a mind because it's rare for you to get to the optimal solution with your first idea.

  • If you're confident enough that your first idea is Thea optimal solution, then go for it.

  • But if not, list out a few potential solutions before you start coating now on to step two Jews your approach and start quoting here in this example, you might say something like, Well, I think the eatery solution is a good solution.

  • So let me start quoting with that, or if you're not 100% sure, if your solution is correct or optimal, you could also say something like, Well, I think the eatery solution is good.

  • Should I start quoting with that just by asking that question?

  • Should I start coating?

  • You're communicating more with the interviewer, which is always good in according interview, and you're also making sure that you're going in the right direction just by asking that question.

  • Now I'm going to switch to a Google doc to explain this idea just like a phone interview.

  • But if you're using a whiteboard to solve this problem in an in person interview, it's the same idea I'm going to use suit coat to explain my solution here.

  • But in the real interview, usually you're supposed to use a real language, whether it's python, java or JavaScript.

  • The first thing I would recommend that you do with this type of problem is to write your function header.

  • In this case, it might look like this.

  • Define add one our function with the input, given a rate and explain the input and the output.

  • For this function, you might say something like this function is going to take the given array as Theo input, and the output will be the new rate.

  • For example, if you're given 134 as to give an array, the output from dysfunction will be 135 And you might say, instead of modifying the given array directly, I'm going to create a new instance of Honore, and they return that instead.

  • This is necessary in case, for example, when the given array is 999 because in that case, we'll need to return.

  • Honore, whose length is different from the order's not rate.

  • After that, start writing your solution as you explain.

  • The code on this process will be a terrific in nature so you might write a little bit of code on that.

  • You might go back to thinking a little bit about your solution and then write your code a little bit more on my recommendation.

  • Here is to always think, with specific examples in mind as you're right coat.

  • So, for example, with this particular problem, you might say something like, Well, the first thing we'll need to do is we'll need to create a new Easter's off Honore, and then I'm going to create it with the length being the same as the original rate.

  • For example, 134 And if we haven't it's case like this where we have 999 or 999.

  • Then we'll need to create a new ray again at the end of the function and then returned that instead.

  • So to create a new excess of Honore with the same length as yours, no one ensued.

  • Code we might ride something like this result will be the new Yuri, and then we're initializing a nuri, an integer array, let's say, with the length being the same as giving a race length.

  • Another thing, we'll need to take care of is the Kerry.

  • So, for example, if we had 199 and then if we initialize disarray, for example, to 000 then when we look at this number, they will know that the last visit in the new number should be zero, and they will need to carry one to this number.

  • And we'll know that the second number should be zero and then carry one again, and we'll know that this number should be, too, and to keep track off.

  • If we need to carry anything, we'll just initialize a new viable called Carrie.

  • And then we'll set it to one because we need to add one to the last digit.

  • On with the example we saw earlier this example, we saw that we need to enter it over each item or each visit from right to left.

  • So we're going to do that with a four loop leads.

  • Four.

  • Eye from giving her a length minus one down to zero again.

  • With this example.

  • Given array, that length will be three.

  • So given a raid that length minus one would be to which will point to this item.

  • Or that's the index for this item and then I will go from 2 to 1 to zero so that we can it right over each digit.

  • And we'll need to add the carry either one or zero to the current item.

  • The current digit.

  • We'll do that.

  • Waste some ecos given array scar buckets.

  • I the current digit plus Carrie.

  • And if this sum is eager to 10 will set carried to one, because we'll need to carry one to the next number.

  • And if some is not equal to 10 or else we'll set carried to zero on the current digit in the new number or result of scar bug.

  • It's I, for example, if we're examining this number right here, we're talking about this digit that number or results scrubber gets.

  • I should be some mod 10.

  • And this is just to say, if the sum is 10 we should have zero.

  • In result on, if the Psalm ace less than 10 we should have the same number as some in the result.

  • For example, if the sum is 55 month, 10 will be just five now.

  • This takes care of most cases except forthis case, when all the digits are nine in that case, what we would have is we'd have 000 as the current result.

  • And that Carrie at that point will be one.

  • Because, of course, when we're examining this number they carried there is one on one plus nine is 10 and they will have Carrie equals to one.

  • So after the four loop, if Carrie is still equal to one, that means we have a case like this where all that is our nine.

  • We're going to take care of that by creating a new re, assigning it to result with knew in disarray, given array, that length plus one.

  • So we're creating a new ray here, with the length being one item longer than the Given.

  • Every on assuming that this initialize is in the ray.

  • With all the elements being zero, we'll just need to set the first item 21 And that way we'll be able to take care of this case when all the items are nine.

  • After that just return result.

  • And that's my solution.

  • Now step three.

  • Check your solution on discuss performance such as time and space complexity.

  • I've copied over the code we had earlier right here to check your solution.

  • You should walk their code line by line, using maybe a few examples and make sure it works.

  • And here's how I would do it.

  • Let's think of one example for example, 1299 as the input given rate.

  • Then we can just look over this code line by line.

  • Carrie will be one, and then result at the beginning will be, let's say, 0000 because this is just an array of the same length as the original rate.

  • After that, we're going to run a four loop for I from giving a raid at length minus one.

  • Given a raid at length is four, so I will start at three.

  • At it will go to 2 to 1 to zero.

  • When I is equal to three, we'd be examining these elements.

  • On the total will be given a ray scar Rockets three, which is nine plus Carrie, which is one.

  • So the total will be 10.

  • And since total istan Carrie will still be one on the current item off results or real results, scrub rockets I or results public.

  • It's three in this case will be total mod of 10 which is zero, and we go to the next value off I, which is to we're going to repeat the same thing on the current value of result will be zero.

  • Carrie will still be one, and then I becomes one when eyes equal to one total this time will be given a racecar Brackets I, which is to plus Carrie, which is one and so total would be three and see his total is not good to 10.

  • Carrie will be zero, and the result will be three Marred 10 which is three.

  • So the current value off result will be three.

  • And since at that point Carrie will be zero total will be just given a racecar Buckets I plus Carrie.

  • But we can just ignore Carry, since it's Darryl on Total.

  • Here will be one, and Carrie will still be zero on the current item.

  • In the Result, array or results, Car bracket zero will be total mod 10 which is one.

  • And after that, Since Carrie is not equal to one, it's still there.

  • We're going to return result, which is 1300 So that's how you can go through one example to be sure you can go through a few other examples to, for example, 999 or just zero now.

  • In this particular example, the space complexity and the time complexity are fairly simple.

  • Let's first think about time complexity, because we go through this entire array at most once or twice when we create and Yuri in the case off 999 The time complexity is big off.

  • And where N is the number of items in the given a rate, the space complexity will be big off and as well, because the most we create the most space we create is for the new array, which is big off.

  • And and that's the framework I would personally use for cracking a Gu, according to view or quoting interviews from any other company.

  • For that matter.

  • If you like this video, I would also recommend my course on you know, me 11 as sensor, according to be questions.

  • And that's the framework I would personally use for cracking a Google according to view or quoting interviews from any other company.

  • For that matter.

  • If you like this video, I would also recommend my course on you.

  • Timmy 11 a sensor, according to be questions in which I cover 11 of the most essential quoting into me questions to master for your next Cordy interview.

  • In case you're interested in taking the course, I put a discount code below and the description.

  • All right.

  • Thanks for watching this video on.

  • I'll see you soon.

Hey, everyone, my name is y que on I'm a former software developer, Google.

字幕と単語

ワンタップで英和辞典検索 単語をクリックすると、意味が表示されます

A2 初級

Googleコーディングの面接をクラックする方法 - 元グーグラーのガイド (How to Crack a Google Coding Interview - An Ex-Googler’s Guide)

  • 14 1
    林宜悉 に公開 2021 年 01 月 14 日
動画の中の単語