☕ Hard Google Interview Question

A Senior Google Interview Question involving distributed systems and sorting. Pluralsight makes their tutorials free for April! Also, a solution to yesterday's leetcode hard interview question.

Hey Guys,

Interviewing.io is a fantastic resource I wanted to share with you all.

You can book realistic mock interviews with senior FAANG engineers who will give you detailed and actionable feedback on exactly what you need to work on.

Mastering algorithms on LeetCode and system design on SystemsExpert is great, but they don’t prepare you for the pressure and stress that comes from an actual interview setting.

The best part?

You don’t pay anything until you’re hired.

Check them out here.

Special thanks to Interviewing.io for sponsoring Quastor Daily. I’m a user of the service!

Tech Snippets

You’re given 1 terabytes of data and have to sort it using 1,000 computers. Each computer has 1.5 gigabytes of RAM. Sort the data as quickly as possible.

How do you do it?

Here’s an awesome article that goes into detail on how to solve this question.

Some things to consider are

  • Is there any order or pattern in the initial data?

  • What is the read speed of the database?

  • What sorting algorithm do we use?

  • How do we implement K-way merge?

QuanticDev also goes through some follow up questions that the interviewer may ask in his outstanding article.

Pluralsight has some solid tutorials on things like Machine Learning, Distributed Systems, Cloud platforms, etc.

They’re running a special where you can use the product for free for the month of April (no credit card required).

My only criticism of the product is that the videos can get a bit repetitive and slow. It’s usually a lot faster to read books/blog posts on the subject you’re trying to learn.

But hey, it’s free!

Interview Question

Given a positive integer n, write a function that computes the number of trailing zeros in n!

Example

Input - 12

Output - 2

Explanation - 12! is 479001600

Input - 900

Output - 224

Explanation - 900! is a big ass number

We’ll send a detailed solution tomorrow, so make sure you move our emails to primary, so you don’t miss them!

Gmail users—move us to your primary inbox

  • On your phone? Hit the 3 dots at the top right corner, click "Move to" then "Primary"

  • On desktop? Back out of this email then drag and drop this email into the "Primary" tab near the top left of your screen

Apple mail users—tap on our email address at the top of this email (next to "From:" on mobile) and click “Add to VIPs”

Previous Solution

As a refresher, here’s the last question

Given any integer, print the English phrase version of that inger.

Example

Input - 420

Output - Four hundred and twenty

Input - 19,323,984

Output - Nineteen million, three hundred and twenty three thousand, nine hundred and eighty four.

Here’s the question in LeetCode

Solution

Warning - this question is a bit tedious.

There isn’t any option other than manually writing out the ones, tens and thousands in cardinal form, so that’s no fun.

The general overview of how to solve this question is to first break up our number into 3 digit chunks (break it up by the commas).

Then, convert each of those three digit chunks into cardinal form. We do that in a separate function.

After that, tack on the “Billion”, “Million” or “Thousand” based off which place that chunk came from.

In order to convert three digit chunks into cardinal form, we first isolate the ones, tens and hundreds place by using the modulo operation.

Then, we have a couple of dictionaries that maps 1 to “One”, 2 to “Two”, 11 to “Eleven”, 20 to “Twenty” and so on.

We use those dictionaries to convert our ones, tens and hundreds places into the appropriate cardinal numbers and then add on a “Hundred” for the hundreds place.

After we can join the words into our string and return it as the cardinal form of our three digit integer.

The only edge case we have to take care of is if the user enters 0, in which case we just return “Zero”

Here’s the Python 3 code. Not too bad!

Want more practice with real FAANG software engineers?

Check out Interviewing.io!

You don’t have to pay anything until you get that job at FAANG!