## Bloomberg LP Interview Questions

- 0of 0 votes
Write a method that takes an int as input and outputs an int with the digits of the input in reverse, i.e. 12345 -> 54321.

- 0of 0 votes
Write a method that takes an int as an input and outputs the digits in reverse, i.e. 12345 -> 54321.

- 0of 0 votes
in a Hadoop-like system, how do we manage multiple nodes collaborating together without having a master node?

my answer was running a back end job to randomly select a node to be a master node; and whenever the master node goes down, the backend job select a new node.

- 0of 0 votes
Given the following structure Record and we have million of records on disk.

struct Record

{

char[257] name;

int startTime;

char[257] description;

}

Now we want to keep a in-memory cache which is represented in class ManageRecords to perform 2 methods GetDesriptions and GetRecords. Given that we have very big memory and we can use any data structure so that the 2 methods can be performed really quick. Here are the questions:

1. what should be the return type for method GetDesriptions

2. what should be the return type for method GetRecords

3. what data structure should we use in the private part as commented out below

class ManageRecords

{

public:

ManageRecords();

? GetDesriptions(char[] name);

? GetRecords(int begin, int end); //do a range search based on startTime of structure Record

private:

// what data strcture should we use here?

}

- 0of 0 votes
If you run the same program twice, what section would be shared in the memory?

Follow up, is the text portion of memory share? Why not?

- 0of 0 votes
What do you do if your program does a core dump?

(Analyze code dump)

Name all the possible ways a program would do core dump.

- 0of 0 votes
Write a function that accepts an n-dimension array and prints its values--For array of any dimension.

What is the layout of multi-dimensional array in the memory?

- 0of 0 votes
Given a number n, write a function that writes a Fibonacci sequence to number n.

- 0of 0 votes
It was part of a bigger question --a large piece of code.

Implement << operator. What are the differences of implementation as a member function and a non-member function

- 0of 0 votes
What does an iterator in C++ point to in case of a vector vs. list. Where would it point to if the prior links are deleted in the list? In case of a vector if it points to a specific index, where would it point to if the prior indexes are deleted?

- 0of 0 votes
What C++ data structures would you use to implement LRU cache? Show implementation.

- 0of 0 votes
How would you implement this:

`object["String for a security name"]["another string"] = another_object`

- 0of 0 votes
What are the various ways of doing IPC in Unix/Linux? How do you implement it?

- 0of 0 votes
Write a program to accept a nonempty string of alphanumeric characters. Define a “run” as a

consecutive sequence of a single character. For example, “aaaa” is a run of length 4. The program will

print the longest run in the given string. If there is no single longest run, then you may print any of

those runs whose length is at least as long as all other runs in the string.

Example input: a

Example output: a

Example input: aab

Example output: aa

Example input: abbbbbcc

Example output: bbbbb

Example input: aabbccdd

Example output: aa

- 0of 0 votes
Write a program to accept a nonempty string of 0's and 1's as an argument. The program will print the

offsets of runs, each run consisting of all 0's or all 1's, where the runs are longer than 1. For example, if

given "0010011" it will print "0, 3, 5" on stdout.

- 0of 0 votes
For an N-ary Tree find the nearest common ancestor.

Given: rootid and a function which finds and returns the immediate parent of a node.

- 0of 0 votes
For an N-ary Tree find the nearest common ancestor.

Given: rootid and a function to find the immediate parent of a node.

- 0of 0 votes
Given a set of integer dots (like (1,5)), how can you find a pair that has an integer mid-point? For example, (1,1) and (3,3) have an integer mid-point of (2,2), while (1,1) and (3,2) do not. Tell the complexity of your code. What if the dots are N-dimensional?

- 1of 1 vote
Find first unique number in an unsorted array of 32 bit numbers without using hash tables or array of counters.

- 0of 0 votes
There is a large data file with 10 digit numbers. You are allowed to use only 20 megabytes of memory. How would you sort them ?

- 0of 0 votes
Find the longest repeating character in a sorted string

- -1of 1 vote
Player turns are stored in an array like so [1,2,1,2,1,2,1,2]. Make it so that player 1 finishes first and then player 2. i.e [1,1,1,1,2,2,2,2]

- 0of 0 votes
An array contains the following elements [9,6,-3,1,7] and a value is equal to 4. Find a pair of numbers in the array that equal the sum.

- 0of 0 votes
How do you implement stack in stl? What is the complexity?

- 1of 1 vote
I have 5 arrays with integer elements. I want to find the common elements in all 5 arrays. What is the logic?c

- 0of 0 votes
What is smart pointer? How do you implement? What happens with the following: p2 = p1;

What happens P3(p1) (copy const)?

- 0of 0 votes
Picture a restaurant kitchen with tickets of customer’s orders which has a start time, end time of when the order was completed, and price. How would you find the longest contiguous time that tickets were processed within a given day?

- 0of 0 votes
Websites like Pandora recommend music based on user preferences. What kind of information would you need in such a design?

- 2of 2 votes
Given an integer, print out all the prime numbers smaller than that integer.

- 2of 2 votes
Given a binary tree, find out the maximum sum of value from root to each leaf.

`find_Max(Node *root){ if (root==null) return 0; else return max((find_Max(root->left), find_Max(root->right))+root->value; }`