Skip to content

Instantly share code, notes, and snippets.

@sevki

sevki/0intro.md Secret

Last active November 11, 2022 23:29
Show Gist options
  • Save sevki/87497a8fa54cfb6c4995cbfdae53a07a to your computer and use it in GitHub Desktop.
Save sevki/87497a8fa54cfb6c4995cbfdae53a07a to your computer and use it in GitHub Desktop.

Hey! 👋

If you're here, you probably said I need to do a ✌️leetcoding✌️ interview, which is fantastic, but I'd like for you to return the favour and take a very quick pop quiz to asess your CS knowledge.

I'm not an engineer you say! We're playing by big tech rules, which say

An interview is typically different from your day-to-day job.

Preparing for Your Software Engineering Interview at Facebook

So you'll still have do this, even if you're a recuiter.

OK, great! Now that you've come to terms with this being unavoidable, we can begin.

Let's start with some fun stuff

🦆 test

Duck typing in computer programming is an application of the duck test—"If it walks like a duck and it quacks like a duck, then it must be a duck"—to determine whether an object can be used for a particular purpose.

Duck Typing

Without running script below, can you guess the output?

send me an email with the answer in big O notation.

from random import seed
from random import random
from random import choice
seed(1)
class Question:
def __init__(self, question, evidence):
self.question = question
self.check = evidence
def ask(self):
print(self.question)
def answer(self, user_input):
if self.check == None:
self.check = user_input
return None
elif callable(self.check):
return self.check(user_input)
return self.check == user_input
# https://innocenceproject.org/police-interviews-versus-interrogation-fairbanks-four-case-illustrates-important-distinction/
class Interview:
"""
“Interrogation” and “interview” are not synonyms; they have very different purposes and employ very different tactics.
Interviews are used in an investigation to gather information — objective facts — by asking open-ended questions
and allowing the witness to supply the evidence.
Police conduct interviews when they don’t yet know the answers to the questions they are asking.
"""
answers = []
def save_answer(self, answer):
self.answers.append(answer)
return None
def question(self):
return Question("where were you last night at 8:00", self.save_answer)
class Interrogation:
"""
Interrogations, on the other hand, are designed to extract confessions where police already have other
concrete evidence connecting the suspect to the crime.
Most officers are trained in specific interrogation techniques that are intended to be used against
seasoned adult criminals.
Because interrogations are so coercive, there’s a danger in using them, rather than an investigation,
to solve a crime:
They can produce false confessions that blind officers to other objective evidence.
"""
def question(self,):
return Question("where were you last night at 8:00", "10 downing street")
questioning_techniques = (
Interrogation(),
Interview()
)
questioning_techniques_by_result = {
# question is open ended there is no predetermined true or false answer. the answer is always "It depends!"
type(Interview().question().answer("nanyabiznis")): type(Interview()),
# there are correct and incorrect answers
type(Interrogation().question().answer("nanyabiznis")): type(Interrogation()),
}
class LeetCodingInterview:
"""
You will have a limited time for the coding question, so it will be important to finish it in time.
If possible, have a mock interview with a friend to simulate the interview experience.
Be able to discuss the big-O complexity of your approaches.
Don't forget to brush up on your data structures like lists, arrays, hash tables, hash maps, stacks,
queues, graphs, trees, heaps. Also sorts, searches, and traversals (BFS, DFS).
Also review recursion and iterative approaches.
It's important to write your solution correctly and in time, so use the language you are most familiar with.
"""
questions = {
"merge sort": "O(n lgn)",
"quick sort": "O(n^2)",
}
failed = False
def question(self):
list_of_questions = list(self.questions.items())
question = choice(list_of_questions) # randomly select a question
return Question("what is the worst case for {}".format(question[0]), question[1].__eq__)
class WritingSamplesInterview:
"""
Our hiring process is a little different than most: we believe that the best basis for assessment
of an engineer is not through their performance on an arbitrary oral exam, but rather through their own expression.
That is, we choose to use interviews not to assess you as a stranger, but rather to more deeply
understand the complete engineer who your work indicates you to be.
"""
questions = [
"""
The ultimate measure of an engineer is our work.
Please submit at least one work sample (and no more than three), providing links if/as necessary.
This should be work that best reflects you as an engineer --
work that you are proud of or you feel is otherwise representative of who you aspire to be as an engineer.
If this work is entirely proprietary, please describe it as fully as you can, providing necessary context.
""",
"""
A significant challenge of engineering is dealing with a system when it doesn't,
in fact, work correctly. When systems misbehave, engineers must flip their disposition:
instead of a creator of their own heaven and earth, they must become a scientist,
attempting to reason about a foreign world. Please provide an analysis sample: a written
analysis of system misbehavior from some point in your career. If such an analysis is not readily
available (as it might not be if one’s work has been strictly proprietary),
please recount an incident in which you analyzed system misbehavior,
including as much technical detail as you can recall.
""",
]
answers = []
def save_answer(self, answer):
self.answers.append(answer)
return None
def question(self):
return Question(choice(self.questions), self.save_answer)
class Candidate:
the_one_thing_i_know = "O(n lgn)"
line_of_questioning = type(None)
def do(self, interview):
q = interview.question()
result = q.answer(self.the_one_thing_i_know)
#
# uncomment the line below to infer the line of questioning by question results
#
self.line_of_questioning = questioning_techniques_by_result[type(
result)]
def reflect(self):
return self.line_of_questioning
inteviews = {
# https://www.facebook.com/careers/life/preparing-for-your-software-engineering-interview-at-facebook
'facebook': LeetCodingInterview(),
# https://docs.google.com/document/d/1Xtofg-fMQfZoq8Y3oSAKjEgDQCRHx-GMSmPcxdEea4A/edit
'oxide': WritingSamplesInterview(),
}
for interviewer in inteviews:
candidate = Candidate()
interview = inteviews[interviewer]
candidate.do(interview)
print(
"🦆 {interview_type} quacks like a {interview_duck_type}".format(
interview_duck_type=candidate.reflect(),
interview_type=type(interview),
)
)

✨ Origin Story ✨

The apocryphal origin story I've heard but not been able to verify goes like this;

Most people assume that big tech came up with leetcoding interviews, but infact it was invented in 1940s by Sir Reginald Arthur Charles Elite III

Sir Reginald Arthur Charles Elite III

Sir Reginald Arthur Charles Elite III

, who was running a very successful public swimming pool.

After desegregation of swimming pools Sir Reginald's country club was bombarded with applications from minorities, who previously were in-eligable to do apply, and he very quickly became overwhelemed with applications from minorities.

He needed to slow down the applicatons to the pool from nminorities without spelling out NO MINORITIES

The answer came to him in the form of a Elite Swimmer Test! I'll say only Elite Swimmers are allowed!

So in order to determine their elite status I'll start asking applicants something tangentially related to swimming, like sailing, he thought.

It's logical that people who are excellent sailors would be excellent swimmers to. Therefore we can say if someone is an elite sailor, it should follow they are elite swimmers too.

And since sailing education is out of reach for most minorities so it should filter out most of them and if they do show up claiming to have sailing knwoledge, we'll just take them in to a room and quiz them until they admit they don't beling here. And if they pass he thought, they'll have crippling imposter syndrome and will quit soon anyways.

So when like years later Apple, Google, Facebook and other big tech firms were being bombarded by applications, they thought to themselves, how do we achive that one black customer support engineers' wishes to be in every office photo, so he can stay college brochure famous long after he leaves?

They thought about it for a while but the answer to keeping big tech 70% white male, wasn't obvious.

One of the VPs from Google happened to be Sir Reg's Great grandson Reginald Tiffany Elite IV

Reginald Agustus Tiffany Elite

Reginald Tiffany Elite IV

Reg the fourth, took some time off his busy schedule of sexually assulting female colleages and and organised an intercompany off-site in SoHo House Malibu.

He spent a total of 5 seconds to present to hem his vision the "Elite's Coding Interview"

How about we just put candidates in a room and interrogate them for hours. like pop-pop used to at the old country club

The VP from Apple went "Hell Yeah!"

The VP from Facebook went "Hell Yeah!"

The VP from Microsoft went "Hell Yeah!"

The VP from Amazon went "Hell Yeah!"

"Heres the best part, we queston them on Big O" said the fouth.

"It's tangentially relevant, prcatically useless knowledge, that is only within the reach of people who can afford univestiy and specially IVY leauge/oxbridge unis"

The VP from Apple went "Hell Yeah!"

The VP from Facebook went "Hell Yeah!"

The VP from Microsoft went "Hell Yeah!"

The VP from Amazon went "Hell Yeah!"

"Think about it, when was the last time you actually had to use big O"

"I've never used it" said the VP from Apple

"Neither have I" said The VP from Facebook

"I don't even know what big O is" cackled the Amazon VP

"wait really? why is it tangentially relevant? I thought they thought it at universities" said Susan the only female VPs in the room, who was only invited becasue Reg the forth couldn't figure out how to book a confernece room for 20.

They all laughed.

"Big O is to algorithms, what a pinch is to salt."

"It's only good for guestimating stuff. Why would you create your self more guess work when you can benchmark it precisely?" said the VP from Microsoft.

They laughed more. "Ah that makes sense"

"wait one more second" said Susan, "isn't calling it the elite's coding intervivew a bit on the nose?"

"Yes but more importantly than what the girl VP just said" said VP from Apple

"calling it elite might come off as elitist"

to which everybody replied "oh yeah, that's true, good catch Tim, don't know what we'd do without you"

"ffs" murmured girl VP underher breaht. but she was happy, secure in the knowledge that she wouldn't stop attending Grace Hopper Conference any time soon.

"drop the "e", just call it "leet", it's sounds a lot less racist when you say it that way." whispered Justin Timberlak's character from social network.

The VP from Apple went "Hell Yeah!"

The VP from Facebook went "Hell Yeah!"

The VP from Microsoft went "Hell Yeah!"

The VP from Amazon went "Hell Yeah!"

They took rest of the week off to talk about blockchain

and thus leetcoding interviews were born.

And that's how we're able to keep diversity in tech 50 shades of eggshell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment