Linkedin Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

int integralPartOfLog(unsigned int n)
{

    int ret = 0;
    
    while (n > 0) {
        n = n>>1;
        ret++;
    }
    
    return ret-1;
}

- Anonymous January 09, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This won't work for little/big endian machines both.

- Second Attempt March 02, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

I think that's the most obvious way of solving the question.
graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious

@Game programmer -- what's wrong with that code?

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

That's the most obvious solution to the problem. This also states that
graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious
@Game programmer -- what's wrong with it?

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

int log2(int a)
{
int n=0;
while(a>1)
{
a>>=1;
n++;
}
return n;
}

- Anonymous September 15, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 votes

May I ask you to be more specific about the mistake?

- Vincent January 16, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think we can not assume n is integer?

- Vincent January 16, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

hi can you please share the reason behind above being a very bad code. What is wrong with that code? I too came up with a similar solution so I would like to know, where are we going wrong?

- inheritance January 19, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

he's probably just a troll

- heisatroll January 19, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Given a number
n = 2^m + x1*2^(m-1) + ...... xm*2^0 + (x(m+1))*2^-1 + ......
Must have
2^m <= n < 2^(m+1)
So
m <= log(2)n < m+1

m is the digit that the highest 1 appears in binary of n no matter n is integer or float.


By the way, Bitwise seems not apply to float in the scope of C/C++. I'm wondering the question implies we should only focus on integers.

You such a bad interviewer and hopefully the interviewee wasn't going to work with you as well.

- Thanks May 25, 2013 | Flag


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