Google Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

Using Reservoir Sampling, you could basically read from the stream of search queries and add them with probablity = k/k+i, where k is 1 million and i denotes the ith hindi query after the kth hindi query. You are ignoring the non-hindi queries as you read from the stream. When you have read all the queries the k queries you have are randomly selected hindi queries.

- Rajesh Konda June 29, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

How does one determine if a query is in Hindi? Assuming we know how to do that, lookup Reservoir Sampling.

- Anonymous March 05, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The library function getLanguage(Query) is given

- Sachin March 06, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The library function getLanguage(Query) is given

- Sachin March 06, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Sachin, did you even lookup what Reservoir Sampling is?

- Anonymous March 06, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Why should [only] Sachin look up what Reservoir Sampling is? Talk about compulsions :D

- Sidd March 08, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int i=0;
int k = 1 Million;
String[] hinQ = new String[K];
while(reader has not reached eof)
{
String querry = reader.NextLine();
if(getLanuage(querry) == 'Hindi')
{
i++;
if(i < K)hinQ[i]=querry;
else if(random(i)<K)
{
hinQ[random(K)]= querry;
}
}
}
// Also note that if memory space is not enough to hold 1 million querry, you can copy the same file to different location and limit your K and i (where to start and where to end except the last)

- Biroj October 07, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More