Ex-Google TechLead explains the interview process at Facebook for staff software engineer. (FYI, this video is a little more technical in nature.) Check out my new project CoderPro ( ) for 50+ coding video explanations to popular interview questions for software engineers. https://www.coderpro.com Join ex-Google/ex-Facebook engineers for my coding interview training: http://techinterviewpro.com/ Videos of 100+ programming interview problems explained: https://coderpro.com/ Sign up for my FREE daily coding interview practice: http://dailyinterviewpro.com/ Learn how I built a $1,000,000+ business on YouTube: http://youtubebackstage.com/ Get 2 FREE stocks on WeBull (valued up to $1,400): https://act.webull.com/k/S4oOH2yGOtHk... My computer/camera gear: http://amazon.com/shop/techlead The TechLead "ultra-thin" wallet https://amzn.to/2WNhqEP The TechLead custom coffee-maker: https://amzn.to/3dxwrzr Join my Discord: https://discord.gg/pFUBUtE 🎉 Party up: http://instagram.com/techleadhd/ http://twitter.com/techleadhd/ https://www.linkedin.com/in/patrickshyu/ Disclosure: Some links are affiliate links to products. I may receive a small commission for purchases made through these links. #techlead Video Transcript ( This transcript is auto-generated by YouTube and may not be 100% accurate.) Note: 00:00 hey welcome back to coffee time with 00:01 your host X Google X Facebook tech lead 00:03 and it occurred to me that I never 00:05 really explained how I got my job at 00:07 Facebook as a staff software engineer 00:09 making five hundred thousand dollars per 00:11 year 00:11 today I thought I would tell you about 00:13 how that interview process went I landed 00:15 this offer about one and a half years 00:17 ago when I was working over at Google as 00:19 a tech lead I might remind you before 00:22 all the drama about my wife leaving me 00:24 happened before I became unemployable 00:26 for bashing Facebook but this may be a 00:28 path that you would like to pursue as 00:30 well at some point in your future maybe 00:32 not now maybe not ever really I wanted 00:35 to explain why might even give you an to 00:37 survive if you know the information if 00:39 you know knowledge if you can pass these 00:40 interviews you should be qualified for 00:42 the job it would otherwise be like 00:44 saying students I say Harvard somehow 00:46 have some secret bit of information that 00:49 is non-public and then they only tell 00:50 that information to their friends and 00:52 then only those people are able to get 00:53 into Harvard and I feel that this 00:55 information disparity is not fair it's 00:57 not fair for people who don't have those 00:59 professional network connections who may 01:01 be from underprivileged communities so 01:03 that's my perspective about giving you 01:05 guys as much information as you can to 01:07 pass these coding interviews 01:08 all right so Facebook generally has 01:10 three different types of interviews you 01:12 can usually tell which one you may be at 01:13 they have coding systems design and 01:16 behavior so the coding focuses on just 01:19 your average sale each code the type of 01:21 questions and what you have to solve 01:22 some coding exercise and that's really 01:24 what's a I'll go pro which I talked 01:26 about it's going to help you get through 01:27 and a lot of junior engineers they 01:29 stumble on this portion or they just 01:31 miss out on a lot of these problems the 01:33 systems design interview is not so 01:35 focused on coding and in fact they'll 01:36 probably get a little bit mad if you 01:38 start coding too much they want you to 01:39 talk about how these pieces of code 01:41 interact with each other and that 01:43 overall architecture of it and then 01:45 there's the behavior portion in which 01:47 they tend to value your ability to 01:48 handle conflict build consensus lead 01:51 projects push impact and overall have 01:53 good collaboration and communication 01:54 skills because overall programming is a 01:57 team sport for myself since I was 01:59 interviewing for a senior role I had one 02:01 coding question two systems design 02:03 interviews and then one behavioral 02:05 portion and in each of these they 02:06 generally do continue to ask you some 02:08 coding questions so it's not like they 02:10 just ask you one let me tell you about 02:11 the coding questions that I had though 02:13 and there's a good thing I took notes on 02:15 these so I can tell you the exact 02:16 questions I was asked and you can think 02:18 about how you may solve some of these as 02:20 well you can just pause the video as we 02:22 go along here the first question is 02:24 given to duplicate binary trees so you 02:27 got tree a and three B and you're given 02:30 a node and tree a find that same 02:32 corresponding node in those B so you can 02:35 think about how you may solve this by 02:37 remember my approach was I would try to 02:39 traverse one tree find the note and then 02:41 traverse the second tree and see if I 02:43 can find that same note but then I 02:45 realized that there was no good way to 02:47 compare the two nodes the interviewer 02:49 kind of stopped me at that point I had 02:51 to step back and think about it and the 02:53 ultimate approach which I think is the 02:55 right one is to just reverse both at the 02:56 same time and when you reach the node in 02:59 a then you know you've reached that same 03:00 node in the second binary tree as well 03:03 but the main trick here is that even 03:05 though most people may have been taught 03:06 to traverse one binary tree at a time 03:08 doing both treat reversals at the same 03:11 time sort of test your mastery of this 03:13 area now the funny thing is for a 03:15 standard interview I think this would be 03:16 the only question but I actually ended 03:18 up solving like three questions in the 03:20 single session so the second question 03:22 they asked was given an array like one 03:25 zero zero two five zero move all of the 03:27 zeros to the right to the end of the 03:29 array and again this isn't necessarily 03:32 so difficult but the challenge is to do 03:34 it in like a single pass linear time 03:36 algorithm make it very efficient and 03:38 come up with the proper time space 03:40 analysis and one brute force technique 03:42 is you can go through the array find the 03:45 first zero and move it to the end go 03:46 through the array find the next zero 03:47 move it to the end and you just keep 03:49 moving these values and that's probably 03:51 going to take quadratic time n square 03:53 time because you got to go through n 03:55 iterations and for each iteration you 03:57 may have to shift and more elements the 03:59 more optimal solution can be done in 04:01 linear time and constant space you keep 04:03 in the index to the last item in the 04:05 array and anytime you find the zero you 04:07 just swap that element with the last 04:09 item and then you move that last index 04:11 one left and you just keep going like 04:13 that and then you can process through 04:15 the whole range it's a pretty ridiculous 04:17 question but you just got to play that 04:18 game 04:19 the next question is check of a string 04:21 of parentheses valid a very common 04:23 question you always get asked this type 04:25 of thing you can either solve that using 04:27 like a 04:27 Hunter but if there are multiple 04:29 different types of parentheses then you 04:30 can use like a stack and when you 04:32 encounter and open the in parentheses 04:34 you push that on to the stack we 04:35 encounter a closing parenthesis you pop 04:37 that off of the stack and you check that 04:39 they match and then there's a follow-up 04:41 question which was to remove all 04:42 unbalanced parentheses another question 04:45 was you're given two binary strings and 04:47 you need to add them manually 04:48 essentially just do a duration using a 04:50 carryover variable that can be done in 04:52 linear time constant space and we go 04:54 over a question similar to this over an 04:56 algo Pro except that they're linked 04:58 lists instead so it's a little bit 04:59 trickier that way and then the last 05:01 question is you are given an array of 05:03 objects small medium and large and that 05:05 you have to sort them in place and you 05:08 know this was a mix of using the proper 05:10 data structures because they weren't 05:11 numbers there's like small medium and 05:13 large objects in there and then coming 05:15 up with the algorithm to sort this 05:17 efficiently the optimal algorithm would 05:19 use no space and it would be linear time 05:21 just do the entire sort in one iteration 05:24 one past I remember the original 05:26 approach I did was first I had a bucket 05:28 of small items and then medium and large 05:30 items combined and I would first go 05:32 through in one pass and move all the 05:34 small items to the beginning and then 05:36 we'll go through a second pass I move 05:37 all the large items to the end and just 05:39 sort the medium and large items so this 05:41 is actually a two pass algorithm so that 05:43 covers the coding and all software 05:45 engineers jr. through senior needs a 05:47 known coding you're gonna be smoked on 05:48 this no matter what level you're at 05:50 which is why it's important to keep your 05:52 skill sharp with algo procom now the two 05:55 systems design questions I got were both 05:57 pretty similar and it's totally going to 05:59 depend on the area that you're in right 06:01 for me I'm an iOS mobile developer so it 06:04 was about building an iOS app 06:05 specifically it was number one design a 06:08 flight booking app and number two design 06:10 a simple version of Instagram so both of 06:12 these questions are about having 06:14 multiple pages or surfaces in an app 06:16 there could be dozens of teams working 06:18 on these and then architecting the app 06:20 structure in the way that multiple 06:21 people can be working on this and then 06:23 handling things like caching offline 06:25 usage event navigation scroll 06:27 performance layout removing inter 06:29 dependencies between different pages for 06:31 the flight booking application the idea 06:33 is that you first search for a set of 06:34 flights you see a list you choose a 06:36 flight and then you can buy the flight 06:37 similarly for the Instagram one is like 06:40 you 06:41 have a bunch of photos then you can 06:42 click on the photo you see the details 06:44 and it's like a two-page app you can 06:47 really go in any direction that you want 06:48 in these systems design interviews is 06:50 super open for me the areas I drove into 06:53 talking more about we're handling 06:54 offline usage scenarios how do you catch 06:57 that stuff 06:58 separating dependencies between surfaces 07:00 so for example the flight booking app 07:02 you may have a payments team that is 07:04 handling the payment view for buying the 07:06 airplane ticket but then you have 07:08 another team that's handling search and 07:10 then another team that handles 07:11 displaying the list of flights and it's 07:14 like how do you structure the 07:15 application in a way such that all of 07:17 these can be independent of one another 07:19 and yet they're able to function 07:20 together and here I will talk about 07:22 having different event handlers 07:24 separating modules out such that they're 07:26 not dependent upon one another and 07:28 coming up with that module dependency 07:29 graph and I had to sort of back step 07:31 they're taking their feedback and during 07:33 the interview I actually realized an 07:35 even better architectural solution that 07:37 we hadn't figured out over at Google 07:38 that Facebook had been implementing and 07:40 they probably just appreciated that I 07:43 was able to collaborate with them to 07:44 solve that right there and then there 07:46 are also questions about holistically 07:48 structuring the app in a way that could 07:50 be suitable for both offline and online 07:52 use and then making the right 07:53 abstractions that say the network layer 07:55 and then I also talked about the UI as 07:57 well so that covers what a mobile 07:59 systems design interview may look like 08:01 for a web it will probably be very 08:02 different for example they'll probably 08:04 be about load balancers databases 08:06 master-slave replication sharding CD ins 08:09 and all of that I think what really 08:11 helped me though was really being more 08:12 interested in other parts of the code 08:14 base rather than whatever I have been 08:16 assigned right like usually people are 08:18 saying to work on one small feature and 08:19 they never take a step back and look at 08:21 how their feature interacts with 08:23 everything else and get an overview of 08:25 the entire code base that they're 08:26 working on if you can take a step back 08:29 and take a look at that that could 08:30 prepare you well for any systems design 08:32 interview that may be coming your way at 08:34 some point maybe now or in the future 08:36 and then lots of other the behavior 08:39 questions which we cover in far more 08:40 depth over in our other program Tech 08:43 interview program where we covered the 08:44 entire interview process start to finish 08:47 but the behavioral questions they really 08:49 dig and they don't accept your first 08:52 answer in fact they're trained not to so 08:54 if they ask you like what 08:55 the most challenging part about this and 08:56 you give some shallow answer like oh 08:58 yeah working with this person and then 09:00 it overcame this challenge they know 09:02 that that first answer 09:03 it's probably like a BS answer that you 09:05 have prepared so they really dig deep 09:06 and this is where it helps to really 09:09 have good examples 09:10 I prepared a number of stories myself 09:11 about the only with conflict tough 09:13 situations at work and I think that for 09:15 this area it also helps you just have 09:16 some good concrete examples which is 09:19 another reason that in whatever role 09:21 you're in it still helps to be pushing 09:23 yourself challenging yourself to do more 09:25 such that it can be something you can 09:26 talk about as you're interviewing for 09:28 your future roles so there you have it I 09:30 remember leaving the interview feeling 09:31 quite positive about it and then two 09:33 weeks later I would receive the offer 09:34 five hundred thousand dollar salary and 09:36 there was still kind of a hard decision 09:38 for me to leave Google to take up that 09:40 offer because I was quite comfortable 09:42 over at Google in fact I felt I was 09:44 probably getting a little bit too 09:45 comfortable just sitting back the idea 09:47 of learning a whole new codebase new 09:49 technologies it just seemed really 09:51 exciting to me at the time so I made 09:52 that switch turned out later to be one 09:55 of the biggest mistakes of my life but 09:57 that's another story 09:58 so that good for me it was a little bit 10:01 more of a technical video but I gotta 10:03 keep my street cred up as the tech lead 10:04 if you liked the video give it a like 10:06 and subscribe and I'll see you next time 10:08 Thanks bye