Bloomberg LP Interview Question for Software Engineer / Developers






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

use array int a[9]. The number is the array index, a[index] represents how many of this number received so far.

- john May 16, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Do you mean to say we have to avoid duplicate numbers?
If this is the case we can use HashTable.

- Cookie May 16, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

we can use multiset if we need to account for duplicates

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

what do you mean?
if it is the case just represents a stream of 1~9, you can use any data structure.

- bbs59 June 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hash table or a simple array A[10] will do. Anyways I feel the question is not clear.

- Anonymous June 24, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hash table or a simple array A[10] will do. Anyways I feel the question is not clear.

- algooz June 24, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Question is pretty much clear.

STL: We can use Vector,Deque,List,Multiset,Multimap to store duplicate elements.
Non-STL: An array i.e. int arr[9]; or a link-list.

- Maninder Singh July 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think the question means that there might be an unknown length stream(sequence) of numbers, which lie between 1 and 9.
In this case, something like array A[9] or array A[10] would not be a good idea as the length of the stream is unknown.
Hence, for me, a more correct answer would be a linked list as the length can be variable and would not have to be known at compile time.
Possible drawback of linked list would be that the data(number) we would like to store in each node would be far smaller (shorter in terms of bits needed to represent) than the pointers that would maintain the list.

Any suggestions to get around this issue?

- Dinesh Bhirud July 29, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Array solution is simple, fast and straightforward. Secondly if size is an issue one could make an array of "unsigned long long" which can count a max of 2^64 - 1. That should be more than enough to handle trillions of numbers (18,446,744,073,709,551,615 to be precise).

- Nitesh October 01, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

I was asked this question: "You are getting stream of numbers between 1 to 9 (this may contain duplicates). You have to maintain these numbers in SORTED array (don't discard duplicates). Which is the best data structure you would use?"
Answer that I can think of is: link list, because array is bad idea as number of elements is unknown. With link list, insertions are faster so maintain a sorted link list and as you get a new number, insert it at a proper place in link list.

- DP October 13, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

how abt using a binary search tree...insert element at root and it finds its location..if there is duplicate place the number in either the Successor/Predecessor...operations are performend at o(log n)..its way better than linked list..

- bla October 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A balanced AVL tree or a red black tree wud be the best since the worst case insertion & lookup times are O(logn). But, extra time may be consumed for node rotation & tree balancing. Hashmap is a bad approach wherever sorting is required. Hashmap is good if we need to deal with duplicates & want O(1) access time. So, balanced binary is the best i can think of.

- Helper December 17, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

How about we have an array of structures. The structure has 2 fields. The number and the no. of instances that the number has occurred. This solution can solve the space problem as well

- abhimanipal February 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It depends how those numbers will be used later. It may appear that we don't need to store them at all. The question doesn't say about it anything.

- Anonymous June 08, 2010 | 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