Bloomberg LP Interview Question for Financial Application Engineers


Country: United States
Interview Type: Phone Interview




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

if the stream if items is in time order. queue could be used to store the item, and only keep last 60 seconds items

- a0 November 24, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

array of structs, sort them according to timestamp and add the 'i's of last 60 seconds (calculated using the difference of timestamps) - O(nlogn)

- ruleZ November 24, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Array is not a nice way to store this, what if a record gets deleted in between somewhere, algorithm goes bust. Linked list (preferrably a doubly in case have to handle past as well next set of records). Doesn't need to be a stack or queue, but for this particular question a stack i more preferred, since last 60 sec data is to be referred, as and when an object is added, that becomes the current timestamp (which needs to be popped) and from there 60 sec backward. So as the item is added, pop that and count 60 sec backwards. If the question was sum of next 60 items, then that kinda points towards a queue. But since we would not be able to answer both these questions together by using a stack or queue, simply implementing a doubly linked list would serve the purpose.

- anon November 26, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think deque STL container, and only keep last 60 seconds items as "a0" said

Double-ended queues are sequence containers with dynamic sizes that can be expanded or contracted on both ends

they allow for the individual elements to be accessed directly through random access iterators

The complexity (efficiency) of common operations on deques is as follows:
Random access - constant O(1)
Insertion or removal of elements at the end or beginning - constant O(1)

so you can insert the new items at the end of the deque and remove the exceeded items from the beginning
and because the Random access constant O(1) you can count the 60 seconds items very fast with complexity O(n)

- engkfke January 12, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Min-heap with insertion time as "time_t", where one periodically peeks heap to find oldest element and remove if its older than 60 secs (current_time - time_t).
Insert new element.
Keep a sum var which adds every new element inserted and subtracts value of removed node.

- prodigy January 16, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Stack would be a solution. LIFO principle. When you pop items compare it to the time. if less than t-60, keep popping items out. If greater than t-60, stop popping items.

- itsmeamit January 18, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Deque works best here. Assumptions: a) timestamp is filled with current time when we store the Item b) we discard old items. If b) is not valid, I'd use a vector and an index/iterator to the tail within 60 sec window.

- mike800 May 16, 2016 | 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