## Bloomberg LP Interview Questions

- 1of 1 vote
Given a map represented as a 2d array with only 0’s and 1’s. An island is a group of connected 1’s. Find out how many distinct islands(can be rotated).

eg:

1 1 0 0

1 0 0 0

0 0 0 1

0 0 1 1

return 2.

- 0of 0 votes
Given two positive integers represented as linked lists, provide the sum of the numbers as a linked list.

`1->2->3 4->5->6 ----------- 5->7->9 1->2->3 4->5 ----------- 1->6->8 4->5->6 7->8->9 ----------- 1->2->4->5`

- 0of 0 votes
A company's organizational structure is represented as

1: 2, 3, 4

In the above employees with id 2, 3 and 4 report to 1

Assume the following hierarchy.

1: 2, 3, 4

3: 5, 6, 7

5: 8, 9, 10

Given an employee Id, return all the employees reporting to him directly or indirectly

- 0of 0 votes
producer consumer problem

- 0of 0 votes
Define a singleton class

- 0of 0 votes
You are given an array of values, (not necessary integers or positives) and a value. You have to print all the pairs whose sum is given value. Write a general method which can accept integers, float, doubles, long, or any other thing where this make sense.

- 0of 0 votes
1) write a concurrent singleton class.

2) Write a factory method class, and how it is used

3) Define a sealed class.

4) What if we want to replace sealed class with another class and use this new class where ever we have used our sealed class, how do you do that.

5) What would you look in a code review?

6) Do you know about adapters, bridges design pattern

7) Define async await method, how do we read data in task library

8) What are the other methods of making your call multi-threaded

9) Do you know Linq queries

10) How to make defer/no defer execution in Linq Queries.

11) Where do you use singleton class, give at least three examples

12) When we use singleton class and when static, both have the single instance.

- 0of 0 votes
You are given an array of stock prices, You have to return maximum profit one can make when buying once and selling once. Consider, you are buying one stock only.

- 0of 0 votes
You are given set of strings, you have to print out the could of each distinct patterns. Please consider anagrams as same pattern and even the char count does not matter.

Ex:

abbba

ab

ba

abcd

abdc

adbc

aabddc

output:

ab: 3

abcd: 4

- 0of 0 votes
You are given three type of data sets.

Type 1

Data size: 4 billion

Distinct Data: 1000

Type 2

Data Size: 4 billion

Distinct Data: 2 billion

Type 3

Data Size: 1000

Each Data is of length 100 million byte

What kind of data structure would you use to answer search/insert/remove queries for each data types?

- 0of 0 votes
Implement pow(x, n)

- 1of 1 vote
Pick three numbers a, b, c from an array of integers to get the maximum product a * b * c.

Began with the O(N^3) solution. Then the interviewer give clues on optimization by sorting the array.

- 0of 0 votes
Q1. You are given a binary search tree (with unique values) and two values. You need to find their lowest common ancestor. (Expected Complexity O(log(n)) + O(1))

Q2. Now let's assume the tree has duplicates, and when a duplicate number come, the insertion logic chooses left node. (Expected Complexity O(log(n)) + O(1))

Q3.Now let's assume the input tree is a binary tree instead of the binary search tree.(Expected Complexity O(n) + O(1))

- 1of 1 vote
You are given a vector of integers. You have to delete the odd numbers from it.

Expected complexity is O(N) Time and O(1) space

- 0of 0 votes
One question containing multiple questions

1) Define the structure of a function which takes an array of size n as input and returns True or False.

2) Write a function which takes an array as input and returns a string containing all the elements separated by a comma.

Ex : [0, -45, 9, 10] => "0,-45,9,10";

3) Write a function which takes two arrays ass input, and returns minimum common element in them.

Ex : [0, -90, 45, 10, 4], [4, 8, 90, 45] => 4

4) Now let's say, the function takes an array of arrays, and each array is sorted. now, returns their first common element.

Ex : [0, -90, 45, 10, 4], [4, 8, 90, 45], [-1, -3, -5, -7, 10, 4], [24, 35, 78, -90, 56, 4] => 4

- 1of 1 vote
You are given an array of integers both negative and positive.

Print the maximum continuous sum of the array and if all the elements are negative, print the smallest of them.

Ex : [-20, -5, -2, -9] :> -2(-2)

Ex : [20, -19, 6, 9, 4] :-> 20(20)

Ex : [10, -3, 4, -2, -1, 10] -> 18 (10, -3, 4, -2, -1, 10)

Thanks velu007 for pointing out the mistake

- 1of 1 vote
Define a graph using Adjacency list where node and graphs are different entities, for example, Node is a struct/class and graph is set of nodes.

The graph is an acyclic directed graph(may be a forest not necessarily connected).

Write an assignment copy constructor for this graph.

Please note that the copy constructor should create a new copy of the graph, including all its edges and vertices. Interviewer called this deep copy.

- 1of 1 vote
Given a list of URLs entered by a user write a program to print unique and most recently used URLs. For example if user entered the following: -

1. google.com

2. yahoo.com

3. wsj.com

4. google.com

The output should be :-

1. google.com

2. wsj.com

3.yahoo.com

- 1of 1 vote
Calculate and replace repeated characters in a string with their number of occurrences.

Example :

aaaggbbbbc

3a2g4b1c

- 1of 1 vote
Sort elements by frequency, print the elements of an array in the decreasing frequency if 2 numbers have same frequency then print the one which came first.

- 2of 2 votes
Given points on a plane like (0,0), (1,0), (0,1), (1,1), (0,2), (2,2), (1,2). How many rectangles can be formed ?

- 0of 0 votes
I was asked to design a stock ticker system. Stock ticker is simply the shortened name of company and its current stock size. e.g. for Apple - "AAPL" -> "115"

He asked me to design a data structure to store incoming stream of stock tickers. Stream can contain same company more than once but all the values of it had to be stored. I used HashMap<String, List<Integer>>. Then he was adding more functionalities to system I don't exactly remember the questions now but one of them was related to calculating some ratio in constant time. Some of the questions were challenging.

- 0of 0 votes
Given a set find its power set. (This question is from CTCI) Interviewer then discussed the complexity of my solution. He asked me to explain him how the complexity is 2^n? As per my solution, I was iterating over an arraylist which contained the set elements so the size of list was getting doubled in every iteration. Hence the complexity (2^0 + 2^1 + 2^2 +.....+2^n-1 = 2^n)

- 0of 0 votes
Given a string, add some characters to the from of it so that it becomes a palindrome. E.g.1) If input is "abc" then "bcabc" should be returned. 2) input -> "ab" output -> "bab" 3) input -> "a" output -> "a"

- 0of 0 votes
You are given a binary tree. Each node in the tree is a house and the value of node is the cash present in the house. A thief can rob houses in alternate levels only. If thief decides to rob house at level 0 then he can rob houses in levels 2,4,6... or he can rob houses in levels 1,3,5,7...Find out the maximum possible amount thief can rob.

- 0of 2 votes
Hey guys, I was asked this question on Bloomberg's pre-interview screening exam and I was wondering how to go about it.

Find the tightest asymptotic bound for:

T(n) = n(T(n/2)^2)

so far I was able to get it to look like this (not sure if correct):

T(n) = 1 / (1 + T(n/2)^2)

From then I made a recursion tree which led me to think that T(n) might be exponential in this case. Do you have any idea where could I go from here? Do you think this has no tight asymptotic bound?

- 0of 2 votes
Returns the zero based index of the first occurrence of any character of str2 in str1

Input:

str1="adf6ysh"

str2="123678"

output: 3

I have solved this by taking second string in hashset and then iterating first string one by one but i need more optimized way.

- 5of 5 votes
* Given an unsorted integer array, place all zeros to the end of the array without changing the sequence of non-zero

* elements. (i.e. [1,3,0,8,12, 0, 4, 0,7] --> [1,3,8,12,4,7,0,0,0])

- 0of 0 votes
* Implement a tick server the has multiple clients interested in different tickers. Clients have Plotters that are updated

* in real-time with the top 10 tickers that have the most price updates on the top. What data structure would you choose

* for the server and client plotters?

- 0of 0 votes
* Royal titles consist of name followed by space and a Roman numeral. Example: Richard IV. The Roman numeral in the title

* can go to L (50). You are given the roman numerals from 1 to 10:

* I II III IV V VI VII VIII IX X. And you are given the 10 multiples up to 50: XX XXX IL L. Numbers between 10 and 50 that

* are not given can be formed from 10 multiples and a numeral b/w 1 and 9. Example: 48 is XLVIII wichi is XL (40) plus

* VIII (8).

* <p>

* You are given an array of Roman titles sort it as follows: sort it on the name unless the names are equal, in which

* case you have to sort it on the ordinal of the numerals.

* Examples:

* Henry II, Edward VIII => Eward VII, Henry II

* Richard V, Richard II, Richard X => Richard II, Richard V, Richard X