InMobi Interview Question


Country: India
Interview Type: In-Person




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

Fill array b with entries s.t. b[0] = a[1]-a[0] .... b[n-1] = a[n]-a[n-1].
Now apply Kadane's Sub sequence sum algorithm on B and Find the indices.
Time O(n), Space O(n).

- VillageMonkey May 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

create an array c and fill it from right to left c[i]= max { b[j] i<j<n}
then 2nd pass create an array d left to right d[i]= min{b[j} 0<j<i}

3rd pass find the ci , di where diff is max corresponding points will give you buy and sell time.

- tomb May 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

create an array c and fill it from right to left c[i]= max { b[j] i<j<n}
then 2nd pass create an array d left to right d[i]= min{b[j} 0<j<i}

3rd pass find the ci , di where diff is max corresponding points will give you buy and sell time.

- tomb May 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

List<float> values;
List<DateTime> times

int startIndex=0;
int endIndex;
float maxValue=0;

BestTiming answer = new BestTiming();

for(int i=1;i<values.Count;i++)
{
if(values[i-1] > values[i])
{
endIndex = i-1;
startIndex = i;
}
if(maxValue < (values[i] - values[startIndex]))
{
maxValue = values[i] - values[startIndex];
answer.bestbuyTime = startIndex;
answer.bestSellTime = i;
}
}

return answer;

- FunCoding May 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

List<float> values;
List<DateTime> times

int startIndex=0;
int endIndex;
float maxValue=0;

BestTiming answer = new BestTiming();

for(int i=1;i<values.Count;i++)
{
if(values[i-1] > values[i])
{
endIndex = i-1;
startIndex = i;
}
if(maxValue < (values[i] - values[startIndex]))
{
maxValue = values[i] - values[startIndex];
answer.bestbuyTime = startIndex;
answer.bestSellTime = i;
}
}

return answer;

- FunCoding May 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

List <StockPrediction> stocks;
BestTiming answer = new BestTiming();

int maxIndex, difference,maxDifference;
int min,minIndex;
max=difference=maxDifference=0;
min=Number.Maximum;

for(int i=0;i<stocks.count;i++)
{

if(stocks[i].values<min)
{
min=stocks[i].values;
temporaryMinIndex=i;
}
else if(stocks[i].value>min)
{
difference=stocks[i].values-min;
if(difference>maxDifference)
{
maxIndex=i;
minIndex=temporaryIndex;
}
}
}
answer.bestBuyTime=stocks[minIndex].time;//or just the minIndex so you can get the value as well 
answer.bestSellTime=stocks[maxIndex].time;

- Ashar Azeem October 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

use a heap .

- hoper April 18, 2014 | 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