Status: Software Developer 1.5 yrs experience
Location: Bangalore
Position: SDE at Amazon
Recruiter reached out to me a week before and then scheduled onsite interviews.
Round 1:
visited[1000][1000];
int dx = [0, -1, -1, -1, 0, 1, 1,1];
int dy = [1, 1, 0, -1, -1, -1, 0, 1];
int dfs(int r, int c, int src){
/*base conditions*/
int count = 1;
for(int i=0; i<8; i++){
dr = r+dx[i];
dc = c+dy[i];
if(dr>=0 && dr<R && dc>=0 && dc<C){
if(!visited[dr][dc] && mat[dr][dc]==src){
visited[dr][dc]=1;
count += dfs(dr, dc, src);
}
}
}
return count;
}Round 2:
Round 3:
Round 4:
/*let us suppose the stream has a definite size for a moment*/
stream[n]= {...};
priority_queue<int> pq;
for(int i=0; i<n; i++){
pq.push(stream[i]);
while(pq.size()>10)
pq.pop();
}
/*return pq elements*/Result: Received the offer.