Google Interview Question: First Interview: Simple quest... | Glassdoor

Interview Question

Intern Interview

First Interview: Simple questions: Write a program to find

  a character (and it's occurrence count) in a string. Scale for a paragraph, to a file that doesn't fit in memory to a large set of files split across a network that don't fit in memory of a single machine. Second Interview: Median finding algorithm - find the median of 'n' numbers and a little bit of binary search tree implementation

Interview Answer

2 Answers


The first interview went good. But the second interviewer was more intent on looking for solutions that were exactly in line with his thinking. A slight error and he'd cut you off and explain the whole solution and literally ask you to code it and not listen to any other 'ways' of doing it. It was his way or his way. Extremely disappointing. The 45 minute interview only allowed me to write about 20 lines of code without any time for me to ask him any questions.

Interview Candidate on Mar 31, 2013

public static float median(int[] a) {
    Random r = new Random();
    return median(a, (a.length - 1) / 2, (a.length % 2) == 0, 0,
            a.length - 1, r);

public static float median(int[] a, int k, boolean average, int s, int f,
        Random r) {
    if (k k) {
        return median(a, k, average, s, f - numLarger, r);
    } else {
        return median(a, k - numSmaller, average, s + numSmaller, f, r);

public static void swap(int[] a, int i, int j) {
    int t = a[i];
    a[i] = a[j];
    a[j] = t;

Rahul on May 3, 2013

Add Answers or Comments

To comment on this, Sign In or Sign Up.