Bloomberg software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
StreamBuffer class that buffers a stream of integer latency samples in FIFO order and supports O(1) access to both the minimum and maximum...Input: Integer(s)Question You are navigating a grid from a start cell S to a destination cell D. Your vehicle has a fuel tank with a maximum capacity. Moving...
Question The Hailstone sequence starts from a positive integer n and repeatedly applies the following rules until reaching 1: - If n is...
Question Design a TradeVolumeTracker class that records trade volumes by ticker symbol and returns an ordered ranking of tickers by volume. The...
Question You are implementing a word filter for a puzzle game. Given a list of candidate words and a set of allowed letters plus one required...
Input: ListQuestion You are given an array of integers and an equivalence function equiv(x, y) that returns true if two values belong to the same group....
Question You are given an N-ary tree where each node has a value and a list of children. Return the 1-indexed level that contains the most nodes....
Input: ListQuestion A string is called uniform if all of its characters appear the same number of times. Given a string s, determine whether it can...
Question Design a StreamPalindrome class that processes a stream of characters one at a time. At any point, it should be able to report whether...
Question You are given an N-ary tree where each node has an integer value. Find the minimum sum path from the root to any leaf node and return that...
Input: Integer(s)Question You are given a list of documents where each document has a name and a body of text. Given a search query word, find and return all...
Input: Listdef min_transaction_cost(prices: List[Tuple[int, int, int]], queries: List[Tuple[int, int]]) -> List[int]:prices = [(1, 2, 100), (1, 3, 200), (2, 3, 50)], queries = [(1, 3), (1, 2)] [150, 100] prices = [(1, 4, 300), (4, 5, 100), (1, 5, 600)], queries = [(1, 5), (1, 4)] [400, 300] 1 <= prices.length <= 10^4 1 <= queries.length <= 10^4 1 <= prices[i][0], prices[i][1] <= 10^6 0 <= prices[i][2] <= 10^4 class KthLargest:def __init__(self, k: int, nums: List[int]) -> None:def add(self, val: int) -> int:k = 3, nums = [4, 5, 8, 2] → Output after add(3): 4, Explanation: The current stream is [4, 5, 8, 2, 3], and the 3rd largest number is 4.Example 2: With Input: k = 1, nums = [] → Output after add(5): 5, Explanation: There is only one number 5, which is the 1st largest by default.Constraints:1 <= k <= 10^4-10^4 <= nums[i] <= 10^4-10^4 <= val <= 10^410^4 calls will be made to add.add will be called at least once.def shortest_path(graph: Dict[str, List[Tuple[str, int]]], start: str) -> Dict[str, int]:graph = { 'A': [('B', 1), ('C', 4)], 'B': [('C', 2)], 'C': []}, start = 'A' {'A': 0, 'B': 1, 'C': 3} A, the shortest path to B is 1 and to C is 3 via B.graph = { 'X': [('Y', 5)], 'Y': [('Z', 1)], 'Z': []}, start = 'X' {'X': 0, 'Y': 5, 'Z': 6} X, the shortest path to Y is 5 and to Z is 6.1 and 1000. 100.k transactions (i.e., buy and sell the stock). Your goal is to maximize your profit. You can assume that you cannot sell a stock before you buy it. You need to implement a function that calculates the maximum profit that can be achieved with at most k transactions.Function signature: def max_profit(k: int, prices: List[int]) -> int:
k = 2, prices = [2, 4, 1, 7, 5] 7 k = 1, prices = [3, 2, 6, 5, 0, 3] 4 1 <= k <= 100 0 <= prices.length <= 1000 0 <= prices[i] <= 1000 def maxDepth(root: Optional[TreeNode]) -> int: root = [3,9,20,null,null,15,7] 3 root = [1,null,2] 2 [0, 10^4]. -100 <= Node.val <= 100 10^4 nodes.stock and each edge represents a transaction cost between two stocks, implement a function that returns the shortest path from a start_stock to an end_stock. If no path exists, return -1.def find_shortest_path(graph: Dict[str, List[Tuple[str, int]]], start_stock: str, end_stock: str) -> int:graph = {'A': [('B', 1), ('C', 4)], 'B': [('C', 2), ('D', 5)], 'C': [('D', 1)], 'D': []}, start_stock = 'A', end_stock = 'D' 4 graph = {'A': [('B', 5)], 'B': [('C', 3)], 'C': [], 'D': []}, start_stock = 'A', end_stock = 'D' -1 1000 stocks. 10,000. 1000. start_stock and end_stock are guaranteed to be valid stock identifiers in the graph.add_stock(user_id: str, stock_symbol: str, quantity: int) -> None: Adds a stock for the user.remove_stock(user_id: str, stock_symbol: str) -> None: Removes a stock from the user's portfolio.update_stock(user_id: str, stock_symbol: str, quantity: int) -> None: Updates stock quantity in the portfolio.get_total_value(user_id: str) -> float: Returns the total value of the portfolio based on current stock prices.get_performance(user_id: str) -> dict: Returns performance metrics like returns over a specified period.add_stock('user123', 'AAPL', 10) → Output: None → Explanation: Adds 10 shares of AAPL to user 'user123's portfolio.Example 2: get_total_value('user123') → Output: 1500.00 → Explanation: Total value based on current stock prices of the user's portfolio.Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free