Acing Google Coding Interview as an 18 year old High School Student
HTML-код
- Опубликовано: 2 май 2020
- For my 50k subscriber special, I did a mock Google coding interview with Clement, an ex-Google engineer. As a competitive programmer, I have a lot of experience with algorithmic problems. Check out my channel to learn more about competitive programming!
Check out the other Google coding interview on Clement's channel: • Google Coding Intervie...
Second channel (William Lin ++): / @williamlinpp4187
Website: williamlin.io/
Instagram: / tmwilliamlin168
Twitter: / tmwilliamlin168
Discord: williamlin.io/discord - Игры
That ex-Google coding interviewer looked impressed! 😎
The frontend of algo expert is one of the best I have seen .
I am not saying that the third problem is easy ; It is tough ; I did remember when I did something like that for the first time ; yes ; indeed ; it was tough.
But the fact is ; the third problem is trivial. It is famous by the name of "Re-rooting technique" in competitive programming ; and this is what tmw used ( Plus the problem is actually simple as compared to other rerooting problems out there )
@@Tacoslover770 lol 0:49
Want to see tmw interview you next time 😆 It will be quite fun and challenging
Yeah, I wonder who is he?😜
He coded the RUclips algorithm to where more of his videos would pop up in your recommended.
William or Clement?
@@alibee2083, Clement, then William hacked it and corrected the error :)
@@SolomonBaka really 🤔🤔
Best midfielder in the world
If only it were that simple -.-
interviewer: does that make sense?
him: yeeehaa
me: wtf jus happened
Same :D
Bruh I never even code and I watched this video, and was so confused all the way
@@alphonsusho8962 me too.. idk why this is my recomended
Alphonsus Ho Even If you were an experience programmer. He’s going extremely fast
@@artarkgaming5997 mashallah tbark allah alhamdulillah inshallah better astagfirullah
(Me who knows nothing about coding): hmm yes yes that looks good
Same lmfao
All i know is simple css code 😂
@@nuclearboy5714 lmao same
I feel soo useless now
Not relatable
Flex
I only know the most basic stuff from C and Cplusplus
Ok. William is being humble here. Pretty sure if this wasn't an interview he would have completed all the problems in 10 mins.
give him some vim and in 5 minutes he would be done
Lol
It's okay.
Actually, most of the engineers, who work in G/F can complete this in short period of time(this is as easy/medium questions from leetcode) but coding interview it's not just about problem solving. So... Sure, for competitive programmers of this level, this questions is very easy, because they are easy even for not competitive programmers :D
Yeah but in a company in the caliber of Google it isn't just about solving the problem, it is working with your team, explaining, and collaborating.
It’s an interview, it is just as important to explain your thought processes as it is to get it correct
I have no idea what is going on, but I still watched the whole thing
Same 😂
same bro
This is too smart and handy for his age. Or I am too dumb for my age. Because I am also 18 but can not solve those things.
@@OFaruk58 I had 0 programming knowledge at 18 lol
Honestly although coming up with the solution is hard but understanding what he saying is pretty easy. So, I think this comment is sarcastic.
Bruh I feel like a useless human watching this
This isn't the point of life
cuz you rely on school, universities and don't self-educate.
Hahahaha
You’re not!
God created you for a reason
I have no clue why I’m watching this and why I can’t stop as if I’m absorbing information, even though I’m fucking clueless as to what’s happening
That’s exactly what I was gonna comment 😂 literally watching the whole thing bc it’s just interesting how smart people talk to eachother
Word^
I had no idea how to do this but listening to him explain it I was like o I see what you did like I was following along and understood. Nuts! Good communication on the code.
@lil clit7 absolutely yes, he is one of the finest youtubers in the world if its not him then who
I only understood the first part of the first problem
"Am I allowed to Google the solutions?"
This should have more likes
Programming in a nutshell
Google Interview in an nutshell
This coding interview is so much more practical than regular interviews. Like where do you see yourself in 5 years
there are multiple interview stages, im sure they ask those kind of behavioural and other kind of questions in later interviews. they first filter out ppl through technical interviews
law school is great for undergrad
usually, at least for all the internships Ive applied to, its the opposite. Behavioral phone interview, behavioral interview in person / on zoom, then technical @@fruitygranulizer540
Obviously this is a technical interview
*"The left property, the right property"*
Me: Ahhh, yes its Real Estate
brooo that got me LMAOOO
it's free real estate
“They’re speaking the language of the gods.”
vegita found
Literally what i was thinking💀
🤣🤣🤣🤣nah fam they alien 👽
@@sakibmullick 🤣
> Solves leetcode medium
> holy shit I'm so smart
> goes on this channel
> gives up, cries
life is not fair guy, get used to it
God damn 18 year old gets this problem instantly im sitting here like 👁👄👁
cant solves even the homework, goes on leetcode easy, can't solve it , give up, cries.
how long do you guys think he has been coding? Life is indeed not fair but you must understand that coding is a skill that takes years and years of practice to get to this level.
a_bombchu pretty sure his mom had a god damn computer in her womb
"Alright that was like a introduction question" ...... Me: "oh"
And hes a high school student, dang. I can't imagine understanding this stuff in high school.
Same here lol
You won’t I’m in high school and I didn’t even understand this lol
i’m in high school and i take some java programming classes and they still are confusing
@@ohreally4752 I think he uses c++ or c as his go to. Not sure though cause I found him recently
@@wolfgod1664 fr lmao
I have heard about only one tree in my life ; that is Christmas Tree 🎄
and family tree which i made in 2nd or 3rd grade
Me: *furiously typing*
Interviewer: what’s going on? I’m not seeing anything on the Google Doc?
Me: *on stackoverflow*
lol.
You are hired
@@DjQwEEkPTinBF Sir, we have found a new CEO
time stamp
@@e2k220 are you that dumb?
Hey guys this is so legit I tested w Google interview and failed but the way this video is presented feels exactly how I felt during my interview. Good luck to you if you are planning to interview =)
i don't even know what he's doing but i like it
i don't even know what he's saying but i like it
@@user-sj2vp9mk5t i don’t even know what am I watching but i like it
@@tejas1027 I don't even know
@@budjawa457 I dont
I
So much fun to see. Still in my first year of studying programming, but it's so fascinating to see him think. Very organized way of thinking and obviously very smart too. Hoping I'll be as fluent with it as him in a few years!
hows your journey of programing going so far
How’s it been
@@justyashin476 He's too busy architecting a solution to the knapsack problem to respond to us plebs
Bruh im done, im currently in my second semester for cybersecurity and after seeing this im out
You can do it!
Don't give up bro
Bro giving up is the end of all ends. Just keep pushing even if u feel like ur not progressing
Just try to understand things topic by topic. You will be more brilliant than you know.
bruh don’t do it keep goin
*interview starts for Google *
Interviewer: alright let’s get started
Me an intellectual: can I use Microsoft Word instead of Google Docs?
Interviewer: Get out
Caleb city
Lmao 🤣🤣
Wkwkkwk
Hahahahaha
A more eloquent solution for Prompt#2
For each node, add the sum of (original full tree) depth and re-iterate down to zero adding those sums also.
e.g. Node#8: its original depth is 3, therefore we know it can be used in up to 3 (sub) trees, each time decreasing in depth. So the total from this node is 3+2+1+0 = 6. The same for Node#9. Node#5 would be 2+1+0 = 3.
Add for all nodes and you get 26
yep i had the same idea, using a map we can store depths of every node from root node and then we can just do dfs from root node adding contribution of every node i.e n*(n+1)/2 , where n is depth of the node from root node .
After I watched your interview with Clement, I was so impressed. Your ability to solve this complex problem was very inspiring. You had me subscribed from day 1. Continue to code!
He is the chosen one to take down Google
You were supposed to destroy them, not JOIN them!!!
he looks like the lil Asian key maker in Matrix in that tiny room!! just way younger lol
I thought I was doing well because I could solve the first part... then they kept adding more and more complexity and I couldn't keep up lmao. I have to re-watch the second half of this video, great job.
At least u solved the first part
11:56
William: "Does it make sense so far"
Clement: "Yes"
Me: No. I haven't understood anything.
It's okay, Clement said yes to keep the interview moving along but he was lost more often than he let on.
interviewer: "so now let's move on to something completely different"
...
"so let's go back to that binary tree..."
Well to be fair it's almost shifting the entire try, so the tree isn't really static anymore persay
Lmaooo
Interviewer: *speaks coding language*
Him: *explains coding*
Me: yes that makes sense now
Me: I understand it a part of it !
I'm happy for you, William! I wish you all the best :)
RUclips finding yet another way to make me feel like an idiot
Tbf it doesn't need much inspiration
Wow inspiring, more video like this please for learning purposes. Thank you! 🙏🏻
William is definitely being humble and acting like in a real interview (slow down and communicate). Great to watch. Thanks for sharing.
I actually came up with BFS in mind first and wonder am I missing anything here if using BFS (for the first two prompts)?
BFS should work fine too
as a high school student ???
Me: OK, shredding my university degree right now.
Nah man at least you got a degree. :/
Lol. Too bad you can't shred your student loans too
That's like seeing Michael Jordan play basketball and then going home and burning your hoop! People are better at things than you, but that doesn't mean they're better than you.
He's been at it for a lot longer than most, so he deserves it. US Competitive Coding medalist.
@@coolmonkey619 LMAO
Just watched your Mock interview with Clèment. Great job! I'm very impressed. I started coding for fun. Subbed! Looking forward to your future videos!
wow Bro . William's voice is so soothing .
I can listen to his voice at night and fall asleep . I'm not implying that it is boring , instead it is very relaxing and it gives me tingles (like ASMR) .
For the 3rd problem, since you're only asked to return the sum of distances to the target node, I don't think you need another dfs. In the first dfs you updated the target node with the info you need. So after dfs1, ans = p.second - (target->sz) + (p.first - target->sz).
And here i am 24 years old jobless getting rejected in all interviews
better days to come brother... many of us in the same situation. keep you head high!
Bhai koi baat hmare bhi din ayenge
Same here... got my bachelors back in October and still no job offers, only interviews with role play crap...
But your Sharma ji ka beta🙃
Keep optimistic my friend. It will come.
Idk anything about coding but this video made me want to learn how to code! I been trying to find a hobby but this is fascinating and fantastic job!
Great job!!!! I see a bright bright future ahead of you.
Just imagine Clement wrote the problems in text with all the inputs...William would solve all of them like in 10min xD
Well, thats coding round. Its more like interview simulation. Interviewer dont give question in paper. They will give you example and then start with all your butt power..
I'm coming up in my senior year of college for software and I feel like I could of came up with these solutions but not nearly as fast. With a whiteboard and 3-5 hours it would be possible, but this guys quick with his thought process
You came up with the optimal solutions so quick!
Inspirational AF. Both of them hella good at what they do
I am sitting here at 4 in the morning and this came across my feed and I felt I had to watch the entire thing. I have been in IT since I was 14 and I will say I had no idea what the hell was going on the entire time lol. Took coding in high school but I knew in a few days it wasn't for me. Props to you man.
Same with me. First time I tried coding in Uni knew it wasn't for me. I guess it's one of those things, that you either understand or don't.
24:19 Clement smiles when tmw makes progress 🙂
That's a hard question good job I am keeping watching your videos are so helpful improving my skills in understanding problems.
I swear, I had also learned of everything in what was said here from an Algorithms book but I don't know it as thoroughly as him. I enjoyed this!
Practice and passion makes someone good at something? Woah, I would've never guessed.
Imagine being qualified for Google after High School. Nice work, I will follow your channel and see your progress, it's really interesting.
Being qualified and acing the technical part of the interview are different things
bro he is OVER qualified
@@user-gq7sv9tf1m You'd be surprised. I have a classmate at Stuy HS who graduated with us at 15... he went to MIT and finished by 18. We were class of 2008. He was a VP at Google by 22.
im drunk rn but i will pay ALL my attention to this video, normally id for sure not watch this video bc of my pride but i LOVE this type of content bc i actually understand it. THANK YOU WILLIAM
Great Job William continue!
*I feel Like I got Smarter and big-brainier just by watching this guy ace this interview!*
The colab we never knew we needed
Keep up the good work clement..could you please make a video on commanly used approaches or ways to solve competitive programs with william
I wish you would make videos themed on how you got good. Timeline, skills acquired, projects from first to recent, how long do you practice daily, what have you studied, what do you suggest for people to get good or to your level?
For the 3rd question, even adding the parent node is helpful for using DFS/BFS to solve the problem, but your creative thinking for this question is so cool and the coding for the last question is so amazing. If the interviewee ask to figure out all sumDist for all node, then this solution only need O(N). But the way to add parent node will need O(N^2).
adding parent node would be really helpful, but i'm not so sure an interviewer would allow it. the stuff he added can be directly calculated without changing the input type using functions he previously created. adding a parent node, however, cannot be done without changing the input, or creating a new function to store the parent node for every node
Finally joining William Lin Fan Club, I hope tmw spirit will give me strength
Салам Алматыдан
Thanks, this was quite instructive!
The first question can be seen easily as a sequence. Each node in the rth row has depth (r-1) and there are 2^(r-1) such nodes. So it's just the sum of (r-1)*2^(r-1) where r goes from 1 to n, where n is number of rows. Correct me if I'm wrong.
That “and 5” really was his time to shine
11:57
"Does that make sense so far"
"Yup"
What you don't see is him quietly going on StackOverflow wondering what the hell he just said
Dudee the kid is impressive considering the fact he is in high-school, but this video is what you learn in like the 1st year of computer science in like 2 chapters (graphs and threes) in the subject algorithms and data structures.
@@joaolourenco5279 how does this apply to software engineering?
@@putinsgaytwin4272 it's because you are manipulating data structures with algorithms, ex:heaps.
@@joaolourenco5279 but when I've been graduated for 5 years and haven't done a single thing with trees since then. I forgot it all
@@joaolourenco5279 no it's not... And also it depends on your own tendency to grasp that stuff... I had data structures and algorithms in my 2nd year of college( I'm in 4th currently) and 95% of my classmates still don't know shit about it .. although I'm pretty good at it but the teachers in my college didn't teach us how to code it... They just taught it on a theoretical level and expected us to code it out ourselves... well of course it's better doing it on your own instead of someone teaching you the whole code but this is one of the reasons my friends still don't know shit about it lol
this guy nailed it easily .. he's young, sharp, still flexible .
I wish parents was more caring about their children learning good stuff in their free time instead of wasting time on social networks and wasting time on other stuff ..
this guy is amazing . I wish my kid one day will be even x10 sharper ! XD
crazy how freaking brilliant some people are
"just high school student" - funniest shit i've ever heard. Common high school student doesn't have almost 3k CF rating
This must be how aliens feels like when they hear our language
I'm actually a little jealous... I wish I had your passion at that age. Super impressive either way, you're an inspiration!
I'm 21 and pretty ok at programming, I'm amazed how fast this dude's brain works (talking about the rest of his kickstart videos cuz this one was pretty straightforward except the 3rd problem cuz it was genius of his to design that formula so quick). I wish I didn't go to college and instead I coded day and night to reach his level at that age lol
So he did these challenges before, why he did it so fast :D So if you practice codewars a lot, can did the same
don't worry these problems are easy and his solutions are more complex than they're supposed to be.
you dont reach this level by coding. William is a certified genius with very high IQ
for the 3rd problem you can simply do the bfs from the given node and add all the depths to calculate the final ans . the trick is to add parent pointer to every node similar to the left and right pointer, you can store the parent pointer's in a map .
@@abhinavreddy3204 thanks, but now that I’m working I realise worrying about all of this was pretty stupid. You barely ever need to make use of these irl… just like all those math problems where the character used to buy 1000 watermelons lol
william seems to struggle with english more than the problems itself lol
I mean, English isn’t his first language so...
He's struggling with speaking itself more than the problem being language specific. The reason for that is because he's speaking while thinking of an actual solution to say on the spot.
He has better English than the interviewer or more understanding and that’s his second language
@@Milength when people ask him what languages he speaks, he says them in order of proficiency. First he says 1,200 programming languages then his native language then English.
@@nexus5648 it probably was im not sure. he got medal in IOI for the US and just graduated in Taipei American school(one of the most expensive schools in Taiwan)
For Prompt 2, an easier approach would be to find the depths of each individual node and just add their sums of AP up
yes was wondering why he didn't do that , he just needed to update one line
@@shivanshchakrawarti9289 can you explain that to me? i’m a bit lost, and if you could can you let me know how he added the mode depth and how they got 16 and 26
The complexity of this algorithm would be huge
No
@@brianchallita1050
exactly
I could think of the first solution in about 5 seconds and I'm a happy person not even gonna watch the rest for a next few weeks unless I'm good enough to be able to do the second one too.
Thanks, I know a lot about the stock market because I self educated myself, right now I’m doing calculus in university and I’ll try to develop my skills and learn about coding. 😎
Clement is everywhere!
Like covid :))))
His connections are pretty strong.
I'm even in this comment thread! 😏
@@clem 🤯
@@clem 🤣🤣 nice algo expert...
Very entertaining William. I watched the whole thing, couldn't understand the other dude tho. I guess you should take the AP CS test for me now thanks!!!!!
People like you (i.e., smart).....are going to change the world!.....I wish I could go back in time and start all over again....
Dang bro you killed that problem. Highly impressive
I did quite a few mock interviews from a few engineers from Amazon. TBH, if i aint doing it for the job, its really hard to push myself through the problem to get to a satisfiable approach with optimisation and stuff. But you did a great job over there considering you are really young. Envious.
I’m watching this while eating even tho I don’t understand nothing but deep in side hoping I can understand what’s goin on 😂😂
bro same. the guy says: yeeeaaapppp, me : hmmmm nice.
Exactly maybe I’ll just gain some of this knowledge just through osmosis. Kinda like trying to eat your study guide before the test
Wow i just spent my 48mins 57secs to watch the whole video and trying to figure it out! So helpful thanks 👏
U're really a monster algorithms and coding ... niceee
A much simpler solution for the second problem would be to just change one line of code from the first problem.
ans += dep
Becomes
ans += dep * (dep+1) /2
which is the summation of all number 1 to dep.
The logic behind it is that the node at depth 3 will be part of 3 subtrees. And the corresponding depth of that node for those subtrees will be 1, 2, 3. Similar for nodes at depth 1 and 2.
Thanks buddy, now kindly go back to being a neet
I had no idea what was going on...but i found it interesting and watched the whole thing
I tried to do the same problems side by, i i literally took twice the time he took, with few errors. Literally, you are on the God level.
It is possible to develop this kind of logic very quickly if you know where to look for problems. The problems he got are very standard/basic so he could have memorized a lot of the solutions as well. I personally have seen all of the problems he was given atleast 20 times before and I have only 2 years of experience in competitive programming
you're a super smart dude... big things are in your future
Thanks for the great coding interview. I tried to write my own solutions before I continued watching your solutions. And I just attached my codes here.
Problem 1:
Besides the ordinary dfs, I also wrote a one-line solution that works.
int sumDepths(Node* root) {
return root ? 2 + sumDepths(root->left) + sumDepths(root->right) : -1;
}
Problem 2:
Actually, you can modify your previous dfs solution to get the answer. Suppose the node in the entire tree has depth 3, then node in the subtrees (including the entire tree) has depths 3, 2, 1, 0, sum to 6. That is true to each node. Thus,
int ans = 0;
void dfs(Node* root, int d) {
ans += d * (d + 1) / 2; // instead of d
if (root->left) dfs(root->left, d + 1);
if (root->right) dfs(root->right, d + 1);
}
Problem 3:
I wrote a one-pass solution, but it took me thirty minutes...
vector find(TreeNode* root, TreeNode* target) {
// 0: found target or not(0/1)
// 1: number of nodes
// 2: sum of dists
// 3: dist to target from nodes above / for node below, we don't care
if (!root) return {0, 0, 0, 0};
vector l = find(root->left, target), r = find(root->right, target);
// sum the distances we have so far
int sd(l[2] + r[2]), da(0);
if (!l[0] && !r[0]) { // haven't found target
// add up extra dists to current node
// which equal to the sum of nodes below
sd += l[1] + r[1];
} else if (l[0]) { // found target on left branch
// update the dist from curr node to target
da = l[3] + 1;
// add up extra dists of all nodes on right branch to target
// plus the dist of curr node to target
sd += (level + 1) * r[1] + level;
} else { // found target on right branch
// update the dist from curr node to target
da = r[3] + 1;
// add up extra dists of all nodes on left branch to target
// plus the dist of curr node to target
sd += (level + 1) * l[1] + level;
}
return {root == target || l[0] || r[0], l[1] + r[1] + 1, sd, da};
}
int solve(TreeNode* root, TreeNode* target) {
return find(root, target)[2];
}
I have different simplified and smarter aproach to handle this problem.
"Does it make sense?"
No, it doesn't but still gonna watch it
I did understand most of it but this still inspires me to do more considering im starting highschool
for last problem - if you make tree non-directional (by adding parent pointer to each node) you can treat any node as a root for whole tree and apply solution of the second problem
he was hired at 30:10, jittery with voice change, lip bite, hair adjustment and turns of camera ... now that is nerd for love.
Well observed :D
i really thought this was an *interview* oh well this just passed through my feed lol
Yes I have to say, you have good potential William....it's reminds m my day of first interview with Google ..."your potential will run"
People don’t feel bad some are just gifted in certain stuff, you are gifted in different ways, everyone has it’s gift.
I do work at Google (as or writing this), but these are my personal thoughts. First of all I want to say great job Clement and William. I have really enjoyed your videos and want to thank you guys for the great content. William, you are definitely impressive and have a very good chance of acing your Google Interviews if you choose to give them.
One issue in these interviews is the subconscious bias - Clement knows how good William is so even though he tries to be fair and unbiased he is more likely to give William the benefit of the doubt than an average interviewee would get. For instance the solution for the 3rd problem has some issues - they are pretty basic ones and something that are trivial to catch if you're coding in an IDE (can you spot them?). Still that's something that I (and I guess the average Google interviewer) would bring up after the candidate has written code. Won't impact my hiring decision though.
and here i am, happy because I just moved a div to the center :)
Congrats William! You crushed it at IOI!
In the tree example with sum of depths of each subtree, I think you can add just the arithmetic sum of the depth at each node and that's it .
Im not the only one mesmerized by his pen flipping, right?
you mean... pen spinning?
every asian can do that. dont you know?
No idea why I’m watching this... but it makes me feel happy that there are such intelligent people out there!
For the first question , you can use BFS using some kind of queue , and when adding the children of some node to the queue , add 1 to the field representing the depth : (node,depth) pairs , having node x , or the pair (x,depth(x)) , add to the queue (x.left,depth(x)+1),(x.right,depth(x)+1) and then total_depths += depth(x)
This guy deserve more subscriber.