Flipkart Interview Question for SDE-2s


Country: India
Interview Type: Phone Interview




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

Is it not sum(stock prices over given range) / diff in range ? Is there anything else to this ?

- rams May 10, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Agreed, but the question is how optimally you can do this.
Approach can vary from O(N) to O(1).

You need to come up with best approach :)

- aditya.eagle059 May 10, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Keep an array of running sums
Sum[0] = day[0]
Sum[1] = Sum[0] + day[1]
Sum[i] = Sum[i-1] + day[i]
That takes O(n) to store and compute
For a query day1 to day2 exclusive (so for one day, day1 = day and day2 = day+1
Return (Sum[day2] - Sum[day1]) / (day2-day1)
This is O(1)

- Dr A.D.M. May 16, 2015 | 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