Pergunta de entrevista da empresa Bloomberg

1) Write a method to find the lowest common ancestor of a binary search tree. 2) Write a thread-safe singleton class. 3) Design a parking lot system that will return the number of the next open space. Consider how to optimize the solution if the parking lot was gigantic. 4) Design a history system for a web browser that allows the user to navigate forward, backward, and enter a new URL. 5) Write a method that takes a list of strings and returns a list of buckets of anagrams of those strings. 6) If you have a two-dimensional array representing a maze, return a solution for the path from the upper-left corner to the lower-right corner. You can only move down or right. ie: input: [1, 1, 0, 0] [1, 0, 0, 0] [1, 1. 0, 0] [0. 1, 1. 1] solution: [1, 0, 0, 0] [1, 0, 0, 0] [1, 1, 0, 0] [0, 1, 1, 1] 7) If you have an input character array, for example "_ _ _hello_ _ _ world _ _", write a method to return a character array with the leading and training spaces removed and only one space between each word, ie: "hello_world" 8) Describe how you might architect a system for searching across multiple data sets and returning the results to a client. If some data sets came from external sources, how could you mitigate the amount of code that you'd need to re-write? How can you ensure that all the results are returned to the client at the same time? 9) Describe how you might architect a system that receives a constant stream of data (such as stock ticker symbols and prices) and sends this data to multiple subscribers that only want to listen for certain tickers. Suppose there is a massive amount of data and you discover there is a long delay in the data reaching the consumers. How would you solve this?

Resposta da entrevista

Sigiloso

7 de abr. de 2020

Answer to Q7: void trimWhitespace(string& str) { string::size_type pos = str.find_first_not_of(' '); cout << "pos: " << pos << endl; str.erase(0, pos); pos = str.find_last_not_of(' '); str.erase(pos + 1); pos = str.find_first_of(' '); while (pos != string::npos && pos + 1 < str.length()) { if (str[pos + 1] == ' ') { str.erase(pos, 1); } else { return; } pos = str.find_first_of(' '); } }