Bloomberg logo

Bloomberg

New York, NYFinancial Services

Interview Questions

Cool String Verification

Asked at Bloomberg
technical
strings
algorithms

Determine if a string is "cool" - all characters have the same frequency or can become cool by removing exactly one character.

Examples:

  • "aaabbb" → true (equal frequencies)
  • "aaabbbcccc" → true (remove one 'c' to balance)
  • "aaabbbccccdddd" → false
  • "aabbcccdddeeee" → false

Shuffle Multiple Card Decks

Asked at Bloomberg
technical
algorithms
probability

Implement a card shuffling algorithm for multiple 52-card decks.

Requirements:

  • Handle n decks (n * 52 cards total)
  • Implement realistic shuffling behavior
  • Each card has suit (Hearts, Diamonds, Clubs, Spades) and rank (A, 2-10, J, Q, K)

Function Signature:

struct Card {
    string suit;
    string rank;
};

list<Card> shuffleAllDecks(const list<Card>& all_decks);

Stock Transaction Aggregator

Asked at Bloomberg
technical
system design
data structures

Design a system to track and aggregate stock transaction volumes.

Requirements:

  • Store and update (stock_name, transaction_count) pairs
  • Maintain running totals of transaction volumes
  • Provide sorted output by volume (highest to lowest)
  • Handle concurrent updates efficiently

Focus on:

  1. Data structure choice
  2. Update efficiency
  3. Sorting performance
  4. Memory usage

Deepest Parentheses Extraction

Asked at Bloomberg
technical
strings
parsing

Print the string inside the deepest set of parentheses.

Example:

  • abc(def)g → def
  • ab(cde)f(g) → cde, g
  • a([bc]d){[{{ef}}]} → ef

Valid Frequency String Check

Asked at Bloomberg
technical
strings
validation

A string is valid if all characters of the string appear the same number of times. It is also valid if we can remove just 1 character in the string, and the remaining characters will occur the same number of times. Given a string s, determine if it is valid. If so, return true, otherwise return false.

Examples:

  • Input: "abc" → true
  • Input: "abcc" → true
  • Input: "abccc" → false

Insert Delete GetRandom O(1)

Asked at Bloomberg
technical
data structures
random access

Design a data structure that supports the following operations: insert, delete, getRandom. All operations should be done in average O(1) time complexity.

  See: https://leetcode.com/problems/insert-delete-getrandom-o1/

  Follow-up: https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed/

Share Your Experience at Bloomberg