0 day streak
Anonymous · shared experience20 Jun 2025 · 9 views

Robinhood: Fractional share inventory that stays flattened below one share

Interview question #Robinhood DSA / coding

Problem. Exchanges only trade whole shares, but customers can buy or sell fractions. The firm fills fractional orders from its own inventory per symbol and trades whole shares with the market as needed.

  • Buy: if inventory cannot cover it, buy enough whole shares from the market and keep the leftover. Buying 1.5 shares from empty inventory means getting 2 and holding 0.5.
  • Sell: the sold fraction goes into inventory; once inventory reaches a full share or more, sell the whole shares to the market. 0.75 plus 0.50 leaves 0.25 after selling one share.
  • Invariant after every order: inventory is non-negative and below one share.
  • Dollar orders: convert dollars to shares at the given price first.

Quantities and prices arrive as integers scaled by 100 (42 means 0.42; 1000 means $10.00).

Example. Holding 0.99 of a stock, a customer buys 0.42 at $1.00: inventory drops to 0.57.

Follow-up. Also return an ordered log of every inventory movement with symbol, quantity, buy or sell, and counterparty (market or customer). Watch out: the posted samples had some inconsistencies, so confirm expected outputs.

0 comments

Comments 0

No comments yet. Ask the author something, or add what happened in your own round.