Understand the game
There’s nothing crazy or mysterious about Google interview questions. They’re just programming exercises. You can check out some for yourself. They’re not terribly different from the types of questions you get at, and most of the big-name tech companies. In fact, they aren’t terribly different from the types of questions you’ll get at most tech companies. Again, they’re just programming exercises.
Now, that doesn’t mean they’re easy. They’re not. They’re hard. They’re hard for everyone. But if you understand the game, you can learn how to beat them.
What makes Google interview questions hard is this: Google interviewers aren’t just looking for an answer, they’re looking for the best answer.
Not only that—you need to be able to show why a certain answer is best (a lucky guess isn’t enough). This means you’ll need a vocabulary for talking about how efficiently a function solves a problem, and a method for deriving more efficient solutions.
What we’re talking about here is algorithm design, and it’s the main thing most engineers without a CS degree are lacking.
It’s the main thing Google tests for in their interviews. But it doesn’t take 4 years to learn. More like 4 weeks. Or less.
Today, I want to give you a taste for that algorithm design process. My goal is to prove to you that this stuff is:
- Totally learnable
- Really fun
- A great way to elevate your engineering craft, whether or not you want to interview at Google
A sample problem
The best coding interview problems have 3 answers: a bad answer, a good answer, and a great answer. All 3 answers are correct—what makes each answer better than the last is how much time it takes to run.
In each Google interview, a candidate spends as much as an hour working aloud—with some help from her interviewer—as she tries to derive the bad answer, tweak and improve to get to the good answer, and (if she’s good!) iterate further to get to the great answer.
The fastest way to get a feel for this process is to look at an example, so let’s work through a problem together. As we go, I’ll share the thinking used to derive each answer, so you can see that great coding interview performance isn’t just about being lucky enough to stumble into the right blind insight. There’s a learnable process to solving these problems.
Okay, let’s get into it. Here’s the problem:
Write a function that takes an array of numbers and returns the greatest difference you can get by subtracting any two of those numbers.
For example, if our input is [5, 8, 6, 1], the greatest difference we can get is 8-1, which is 7. So we should return 7.
Let’s solve this together. How should we get started?
The first solution
Here’s my first thought: we’re trying to find the greatest difference. So how about we find all of the possible differences, and return the greatest from among them?
To get every possible difference, we just need to subtract every number from every other number. We can do this by nesting two loops, with each one iterating over our input array. Here’s how that could look in Python:
def get_greatest_difference(nums): greatest_difference = 0 for num1 in nums: for num2 in nums: difference = num1 - num2 if difference > greatest_difference: greatest_difference = difference return greatest_difference
Alright, this’ll work! But how well does it work? Specifically, how long does this function take to run?
In algorithm design, we use a specific language for talking about run time, called . It’s a bit tricky to understand at first, but it comes together quickly with a bit of practice. It’s best learned through example, so let’s jump right in:
We want to know how many steps our algorithm takes as it solves the problem. In this case the question is, “how many times do we have to compute a new difference and see if it’s our new greatest_difference?”How to create signature in gmail How to remove grease from clothes? How to stop spam calls on android? How to shape artificial nail tips What episode does goku go super saiyan What does population mean What does unabated mean How to start a tips and tricks column How to spell congratulations? Tips on how to get rid of a sore throat How to get rid of back acne scars What does predominant mean What does ancient mean Hearts card game how many tricks How to put a curse on someone How long steak tips in air fryer What does tonsils do How to use piping tips with coupler Tips on how to come up with a business idea Youtube how to use decorating tips When does house of tricks close What does adrenaline mean What does abetting mean How to get rid of pimples on forehead overnight What are charros How to image search on google? How to speed up windows 10? How to treat omicron at home? What does graph mean What type of wire is used for making tips for woodburning How to get rid of algae in pool What does tbs mean How to get rid of phlegm? What are the four chambers of the heart Who is the small girl doing the motorcylce tricks What do the different colored tips on bullets mean What does ratification mean How to connect ps5 controller to ps4 What does airdrop mean on iphone How do i do tricks on fifa 12 What are physical and chemical changes How to cook frozen crab legs What does s & m mean Tips on how to survive a tsunami How to pronounce names audio? Tricks when solvimg identities How to get water stains out of wood Tips on how to stop binge eating What does melancholy mean What does different color discharge mean How to get a free house from the government? What does ration mean What does prom stand for Why did jospeh play tricks on his brothers How to train your cat to do tricks What does the bald eagle represent How to stop milk production if not breastfeeding? What are the best trick yoyo tricks Where to buy yellow roses with pink tips How to pass a mouth swab drug test? How to store rice long term How to unlock my iphone Democrat politicians who wear glasses on tips of noses Tips when separating from a business partner How long does it take for sperm to die How long does it take to beat elden ring What does sped mean in text How to do tricks in sonic transformed How to watch movies with friends online? What does tachycardia mean What makeup tricks did will smith wear during "concussions"? What does the purple evil eye mean What does tsa mean How to clear space on iphone What does flagging an email do Tips how to make a sales plan What does gig em mean How to gain muscle What does 750 on jewelry mean Kgb kgb why you gotta play then dirty tricks on me How to transfer contacts to new iphone? What are suburbs What does exigence mean How old can you be to join the army Tips for keeping energy up when pmsing How to leash train a dog? What are amenities What does collate mean What kind of tips would you suggest in regards to acl's. What are mortar and pestle used for How to use siri on iphone 11 How to make cream of mushroom soup? What does ver mean How to get rid of corns How to do tricks on a butterfly xt What does catfishing mean White mushroom tips what spell How to treat broken blood vessel in eye? What does lotus mean Tips when applying for chase sapphire card How to get blood pressure down fast Where do i enter my tips on turbotax What did cherry chapstick really mean How to lower chlorine in pool? What does equal housing opportunity mean How to prevent uti? How to do electron configuration How to get rid of gynecomastia Tips on how to write a rap song How to find body fat percentage How to clean outdoor cushions What does obfuscate mean How to pair apple pencil 2 with ipad? How to stop whooshing sound in ear How to milk a prostate What does efficacy mean How to copy instagram link? What does dysfunctional mean How long does it take for zoloft to work? What tricks can you teach a alaskan malamute Brf shrooms where to find needles tips How to stop binge eating What does punta mean How to get rid of period cramps fast What level does paras evolve What happened to tips bonds What are the kennedy center honors How to season a turkey How to cook over easy eggs? How to get hair dye out of clothes? What are the factors of 20 What does it mean to jump someone What does i.e. mean? How to make love like an englishman What does a head cold feel like What does elevated d dimer mean How to quickly disable a car spy tips What kind of beef for beef tips What time does sam club close What does eskimo mean What is a karen mean Tips to getting your car to start when parked uphill What does negligible mean How to treat kidney infection? How to cut your own steak tips What bowl games are today How to get sense of smell back? Explain how using financial ratios can help spot these tricks. How to connect apple watch to new phone? How to learn new skateboard tricks What does bodycon mean What time does gamestop close near me How to screenshot on s21 What does ibid mean in footnotes How to cook beef tips in a pressure cooker What are the 7 natural wonders of the world How do you replace the rubber tips on walkers What does la stand for What are quaaludes How do quick change artist do there tricks What time does the state of the union start How much does it cost to build a garage? What does of mean What i am looking at tips What does peloton mean How to cook tuna How to journal daily? How to learn english tips and tricks What does embargo mean How long does it take to become a paramedic What does yellow heart emoji mean How to bleach the tips of your hair for guys What are nail tips How old do you have to be to rent a car? How to find popliteal pulse tricks What does artisan mean How to fix hole in frame tips How to edit pdf on mac? What team does russell westbrook play for How to improve mile time tips What does she sheer mean What does live mean on iphone camera How to clean dogs teeth? How does a mentalist do his tricks Airpods pro how to remove tips How to balance chemical equations? How to do french tips on short nails Reddit tips tricks and hacks how to make money daily online What causes your right finger tips to go to sleep If jesus had tricks then why cant i have them hip hop song What are franking privileges What are antibodies What does it mean to overturn abortion rights What does 1515 mean What are tennis shoes What does yolo mean What does bible mean What does derpy mean Vice the black guy who tips Decor tips how to keep cats from scratching walls Why is it rude to give tips in japan What are some boy names What time does hardee's open What does scandalous mean How to find the least common multiple of 3 numbers tricks What does the term let's go brandon mean How to eat a girl out? What is sirloin tips How to get adhd diagnosis How to get rid of maggots in house? How to access downloads on iphone What does jacob roloff do for a living What does it mean when white blood cells are high How do magicians like dan white do their tricks What does it mean when your pupils are small The fray how to save a life What does mia What are the 3 main symptoms of autism Tips on how to recycle What does blood mean How to tell if your phone has a virus? How to make your face thinner How to apply for linus tech tips Where to view the tips and tricks on coaching actuaries What fairs are going on right now How to win chess tricks How to find slant asymptotes? What does tmi mean What law firm is famous for sneaky tricks What does it mean when you keep seeing 1111 How to press flowers in a book How to publish on kindle tips 70003 How to jumpstart a car? How to bookmark on ipad? How to set up voicemail on iphone 11 What do white tips on marijuana mean How to stop being jealous How to write a research paper How to make a paper airplane easy? What do you mean breathe breathe drake What does symmetric mean in math What does a blue orb mean What does voip stand for How long does it take for ringworm to go away What countries are in epcot How to cut lobster tail What are the factors of 22 How long does it take to withdraw money from robinhood? How to write a book review? How to play chess for kids? How-to's & articles tips & tricks electric pressure washers gas pressure washers generac 5991 How to prepare bok choy What does observed holiday mean What does steam mean How to get black dye in minecraft? How to find the standard deviation of a data set? What does cyber mean How to draw mario How to cure a sore throat fast? What does uso mean What are instructional strategies Stories of straight teenage boy who tricks his best friend to suck his cock What does a representative democracy mean How to drop a pin in google maps? Episode of rhoh where kevin tricks the guys and gets hit by trina Tips and recommendations for promoting family resilience when having a traumatic brain injury