Bloomberg LP Interview Question for Software Engineer / Developers






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

kunths shuffle

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

Yep. this works

- Synonymous November 21, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Will this work?
(rand()%n)*n/m

- Kannan October 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

the question is that we should develop our own rand() function

- roshan January 16, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

(rand()%n)*m/n

- Anonymous October 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

(1+rand()%n)*m/n

- Anonymous October 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Given an array of 1 to n.
Choose random number between indices 0 and n-1. Return that element. Replace element with rightmost element in array.
Now choose random number between indices 0 and n-2.
Repeat above m times.

- Metta October 25, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

@metta I am not sure of this but i think your algorithm may not work, since you are restricting each element to be selected only once. In a randomly selected m elements, there is a probability for element to repeat. But in your algorithm, elements do not repeat at all.

- Anonymour November 17, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

oh shit I am sorry. I read the question wrongly.. Ya your algo will work perfectly then. :)

- Anonymour November 17, 2010 | 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