Kristina Chodorow is a core contributor to MongoDB. She has written several O'Reilly books (MongoDB: The Definitive Guide, Scaling MongoDB, and 50 Tips and Tricks for MongoDB Developers) and has given talks at conferences around the world, including OSCON, FOSDEM, Latinoware, TEK·X, and YAPC. Her Twitter handle is @kchodorow. Kristina is a DZone MVB and is not an employee of DZone and has posted 52 posts at DZone. You can read more from them at their website. View Full User Profile

My Google Interviews

  • submit to reddit

When I was a college senior I applied for a job at Google. During the in-person interview, the interviewer asked me to find the median of an infinite series of numbers and I just stared at the board, having no idea what to do. Every idea I came up with that was reasonable for a finite series fell flat when faced with an infinite series.

After one more excruciating (but less memorable) interview, they politely showed me out.

So, I was a bit nervous this time around. However, I am pleased to report that I never was at a loss for what to do and all of the questions seemed pretty fair and reasonable. Most of the questions were basically variations on things in Cracking the Coding Interview, so I figured I’d share them. I got a few more creative questions which are not listed below (I don’t want to ruin a anyone’s “personal” question) but they weren’t any harder or easier than the others.

Note: if you’re planning to interview somewhere soon, you might want to save this, do your other prep, and then go through these questions as a mock-interview.

Here’s what I was asked:

  • Given this weird tree-like thing:


    Find greatest sum on a path from root to leaf (that can only touch one node per level—no going up and down).

    I did a recursive solution that was about six lines long and then she asked me to come up with a way to do it iteratively.

  • Consider a power series:

    a0 + a1x + a2x2 + …

    Suppose we have an interface as follows to get the coefficients: a0, a1, a2, etc:

class PowerSeries {
    virtual double next();

You can take the product of two power series:

(a0 + a1x + a2x2 + …) * (b0 + b1x + b2x2 + …)

Implement next() so it gives you the next coefficient in the product of two power series:

class PowerProduct : public PowerSeries {
    PowerProduct(PowerSeries* A, PowerSeries* B);
    virtual double next();
  • Reverse bytes in an int.

    This was in my last interview of the day, and mental fatigue had reduced me to such a state that I assumed four bits in a byte. I don’t even know where that came from, but that was really embarrassing when I realized it (well after the interview).

  • Write a function to find if a set A is subset of a set B, B is a subset of A, the two sets are equal, or none of the above (you are allowed to use set operations like union and intersection).
  • Part 2 of the previous question: suppose you are given a list of sets. You wish to filter out any set in the list that are a subset of another set in the list. Use your solution from above to find the smallest possible result list as efficiently as possible.
  • Implement atoi (convert a string to an integer).
  • Given a string, find the logest substring of only two distinct characters. For example, given “aabacccaba”, you would return “accca”.
  • Design a cache.
  • Suppose you are on a Cartesian coordinate system. Find all paths from (0,0) to (m,n) that only go through each point once. For example, if you were given m=2, n=2, you’d have the following:


    This would be one possible path:


    Return the number of possible paths. Then extend for negative coordinates.

  • Given two integers, a and b, find the smallest square integer in the range (or return -1, if there is no such square).

Published at DZone with permission of Kristina Chodorow, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)



Henry Kuhl replied on Tue, 2013/03/05 - 4:07pm

Hi Kristina,

thank you for sharing this!

What position did you apply for? Software Developer? 



Kristina Chodorow replied on Tue, 2013/03/05 - 4:57pm

You're welcome!  Yes, it was a "SWE" (software engineer) interview.

Lund Wolfe replied on Sat, 2013/03/09 - 8:46pm

Some of the easier ones remind me of my first ansi "C" programming job.  It is low level coding but definitely tests data structures and algorithms and logic skills.  I'm sure they hire a lot of new graduates and academics and mathematics majors, which is good.

It may predict what you can expect to do in your daily work, too.  Many jobs give you little clue of what your typical day will be like.

Ali Yang replied on Sun, 2013/03/10 - 3:25am

I also met the first question in an interview.  Obviously loop is a better way.  Most of time, the recursion way cannot solve the problem, even it is correct theoretically.

Ann Mann replied on Wed, 2013/08/28 - 1:14pm

Thanks for this post.  Regarding your first question on the binary tree.  Could you share the answer to that? 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.