Microsoft Interview Question for Software Engineer / Developers






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

I don't get the question.

A one-pass scan will do the job. Or I miss something?

- Anonymous February 16, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes! It doesn't have to be hard to be an interview question, right?

let val = neg_infi.
val is equal or less than N.

if (array[i] <= N && array[i] > val)
val = array[i]

- vodangkhoa February 16, 2007 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

subtract N from all...now read again if there is a value that reads 0 then there was a N there...otherwise the value that is the maximum in negative is the closest smallest to N...(-1 is greater than -2)

3 2 1 9 8 5 7
N=6
subtract N gives
-3 -4 -5 4 3 -1 1
read again and the index which has -1 is the answer

- ska February 16, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

it's not necessary have to be only the difference of one

- Anonymous March 03, 2007 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

i mean you dont have to read again just store the -ve value with the index in 2 temp variables ...the one with the max negative value on the numberline is the one

- ska February 17, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Does that make any better ?? I dont think so ... Khoa sol. is right.

- Vamsi December 06, 2007 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int
myFunc(int *in,int size,int N)
{
int flag=0;
int cNo=-1;
for(int i=0;i<size;i++)
{
if (in[i]==N) {
cNo=i;break;
}
else if (in[i] < N && flag==0)
{
cNo =in[i];
flag=1;
}
if(in[i] < N && flag ==1) {
cNo= (in[i]>cNo) ? in[i]:cNo;
}
}
return cNo;
}

int main()
{
int in[7]={13,5,8,2,6,9,10};
int d= myFunc(in,sizeof(in)/sizeof(int),11);
printf("%d is the answer\n",d);
char c=getchar();
}

check this out babes.

- Vishal Goswami March 04, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think the second "if" ( if(in[i] < N && flag ==1) {
cNo= (in[i]>cNo) ? in[i]:cNo; )

is not required as the question says " first number that is smaller than N. "

- Thirumalai March 13, 2007 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

This needs to be done using a hash table . We need to look up for numbers which are smaller than 0 in the hash table.

- Anonymous November 02, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what if there is no value smaller than N?
Thats my first question to the interviewer

- Anonymous November 19, 2007 | 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