Adobe Interview Question for Software Development Managers


Country: India
Interview Type: In-Person




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

Another question from running codding competition:
codechef.com/JAN14/problems/METEORAK
Someone is cheating.

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

```#include "stdafx.h"
#include<iostream>
#include<conio.h>
#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;

int my_binary(int *a, int x, int l, int u)
{
if(l==u)
return l;
int mid=(l+u)/2;
if(a[mid]==x)
return mid;
if(a[mid]<x)
return my_binary(a, x, mid+1, u);
else
return my_binary(a,x, u, mid-1);

}

int compfunc(const void *a, const void*b)
{
const int *pa=(int *)a;
const int *pb =(int *)b;

return (pa[0]-pb[0]);

}

int _tmain(int argc, _TCHAR* argv[])
{
int **a;
int row, column;
cin>>row>>column;
vector<int>v;
a=new int*[row];
for(int i=0; i<row; i++)
a[i]=new int [column];
int x, y;
while(cin>>x>>y)
{
v.push_back(x);
v.push_back(y);
}

int **monster;
monster= new int*[v.size()/2];

for(int i=0; i<v.size()/2; i++)
monster[i]=new int [2];
int k=0;
for(int i=0; i<v.size(); i=i+2)
{
monster[k][0]=v[i];
monster[k][1]=v[i+1];
k++;
}

qsort(monster, v.size()/2, sizeof(int), compfunc );
//for(int i=0; i<v.size()/2; i++)
//cout<<monster[i][0]<<" "<<monster[i][1]<<"\n";

x=3;
y=4;

int cell_count=(y-x+1)*column>(x-y+1)*column? (y-x+1)*column:(x-y+1)*column;
int *new_array=new int [v.size()/2];
for(int i=0; i<v.size()/2; i++)
new_array[i]=monster[i][0];

int index1=my_binary(new_array, x, 0, v.size()/2-1);
int index2=my_binary(new_array, y, 0, v.size()/2-1);
if(index1>0 && new_array[index1-1]==x)
index1--;

if(index2<v.size()/2-1 && new_array[index2+1]==y)
index2++;

cout<<cell_count-(index2-index1+1)<<endl;
return 0;
}"""

- Ananda February 01, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

// MonsterInGrid.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
#include<conio.h>
#include<cstdio>
#include<cstdlib>
#include<vector>
using namespace std;

int my_binary(int *a, int x, int l, int u)
{
if(l==u)
return l;
int mid=(l+u)/2;
if(a[mid]==x)
return mid;
if(a[mid]<x)
return my_binary(a, x, mid+1, u);
else
return my_binary(a,x, u, mid-1);

}

int compfunc(const void *a, const void*b)
{
const int *pa=*(int **)a;
const int *pb =*(int **)b;

return (pa[0]-pb[0]);

}

int _tmain(int argc, _TCHAR* argv[])
{
int **a;
int row, column;
cin>>row>>column;
vector<int>v;
a=new int*[row];
for(int i=0; i<row; i++)
a[i]=new int [column];
int x, y;
while(cin>>x>>y)
{
v.push_back(x);
v.push_back(y);
}

int **monster;
monster= new int*[v.size()/2];

for(int i=0; i<v.size()/2; i++)
monster[i]=new int [2];
int k=0;
for(int i=0; i<v.size(); i=i+2)
{
monster[k][0]=v[i];
monster[k][1]=v[i+1];
k++;
}

qsort(monster, v.size()/2, sizeof(int), compfunc );
for(int i=0; i<v.size()/2; i++)
cout<<monster[i][0]<<" "<<monster[i][1]<<"\n";

x=3;
y=4;

int cell_count=(y-x+1)*column>(x-y+1)*column? (y-x+1)*column:(x-y+1)*column;
//int *new_array=new int [v.size()/2];
int *new_array=new int [v.size()/2];
for(int i=0; i<v.size()/2; i++)
new_array[i]=monster[i][0];

int index1=my_binary(new_array, x, 0, v.size()/2-1);
int index2=my_binary(new_array, y, 0, v.size()/2-1);
if(index1>0 && new_array[index1-1]==x)
index1--;

if(index2<v.size()/2-1 && new_array[index2+1]==y)
index2++;

cout<<cell_count-(index2-index1+1)<<endl;
return 0;
}

- Ananda February 01, 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