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