## ashishbansal1986

BAN USER- 0of 0 votes

AnswersI have recently attended Amazon Interview and got rejected after design round, its happened three times with Amazon in 2 year, i always getting rejected because of design round. please help me to know how should i answer an design question. questions like 1) design elevator control system 2) design whisper-sync feature (used in Amazon instant video platform) they ask me to design End to end HLD LLD i did not get what exactly differ in both, i explain as a algorithm wise, but could not properly by HLD and LLD.

- ashishbansal1986 in India

i mean i searched alot, but could not found a way to answer such question.

Any help will be good for me.

Thanks,| Report Duplicate | Flag | PURGE

Amazon Senior Software Development Engineer Distributed Computing - 0of 0 votes

Answerswe ahve an array of size 30 (say share price for 30 day of amazon in increasing order of day)

- ashishbansal1986 in India

a[0] means first day price

a[1] means second day price like.

need to find the maximum loss in shares in these thirty day.

i gave algo of complexity of big o of n square (n=30 here).| Report Duplicate | Flag | PURGE

Amazon Software Engineer / Developer - 0of 0 votes

Answerswe have one Array size of n.

- ashishbansal1986 in India

suppose array name is a[],

it has property like

a[0] = 0

and a[n] = p (some value).

and in array every two consucative value will differ by most 1 only so the difference beetween any two consucutive value in array is either -1,0 or 1.

find the k in array such 0<k<p.

i give the algo having the complexity of o(n/k).

he want me to apply the binary search on this.| Report Duplicate | Flag | PURGE

Amazon Software Engineer / Developer Algorithm

The code will work because.

all three array are sorted in increasing order.

we get first all 0th positions diff in mindiff.

after that we will found the minimum element in all three element and increase that.

so next time diff will be next diff and possibley miminum.

You are correct.

IT is LRU cache

We can do it in O(1) space.

simply take two variable say

next_negative

next positive

now traverse the array from start , if any position you found any value at wrong position, store that in appropriate variable. and update the index with proper value.

you need to traverse the array with two variable one for positive and other for negative.

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

Why cant we do it recursive

- ashishbansal1986 September 21, 2013main()

{

int max diff = INT_MIN;

fun(arr1,arr2,0,n, &max_diff);

}

int fun(int arr1, int arr2, int i, int n, int * max_diff)

{

if(i>j)

return;

// first take the sum from i to j in both array if it same than J-I is maximum so return that

int sum1 = sum(arr1, i,j);

int sum2 = sum(arr2,i,j);

if(sum1 == sum2)

{

if((j-i)>*min_diff)

*min_diff = j-i;

}

else

fun(arr1,arr2,i+1,j);

fun(arr1,arr2,i,j+1);

return *min_diff;

}