Reported September 2026
Robinhoodhash table

Fractional Share Inventory Flattening

Reported by candidates from Robinhood's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Robinhood OA. Under 2s to a working solution.
Founder's read

The edge case that breaks a naive solution in Robinhood's Fractional Share Inventory Flattening, reported September 2026, is the negative inventory after a buy. Subtract 150 hundredths from 0 and you land at -150, so the flatten step has to handle floor division on negatives, not just a plain modulo. It's a hash map plus string parsing problem with fixed-point math. Nothing fancy, but the details bite. If you blank on the parsing or the rounding during the live assessment, StealthCoder runs invisibly as a safety net and gives you the solution while you keep your hands moving.

The problem

Robinhood can trade only whole shares with an exchange, while customers may buy or sell fractional shares. Maintain the firm's retained fractional inventory for each symbol while processing orders in order.
Every inventory row is symbol/quantity. Every order is symbol/side/quantity/currentPrice, where side is B for a customer buy or S for a customer sell. Numeric fields are fixed-point integers whose final two digits are fractional: 50 means 0.50 shares and price 1000 means $10.00. A quantity beginning with $ is a dollar amount; convert it to hundredths of a share as dollarCents * 100 / priceCents.
A customer buy removes the requested quantity from firm inventory.
A customer sell adds it.
After each order, immediately buy or sell enough whole shares at the exchange that retained inventory is in [0,100) hundredths.
Return final rows in the same symbol order and format as inventory.

Function
flattenFractionalInventory(orders: String[], inventory: String[]) → String[]

Examples
Example 1
orders = ["AAPL/B/150/1000","AAPL/B/40/1000","AAPL/B/50/1000"]
inventory = ["AAPL/0"]
return = ["AAPL/60"]
The retained inventory becomes 50, then 10, then 60 hundredths after whole-share flattening.
Example 2
orders = ["AAPL/S/75/1000","AAPL/S/50/1000","GOOGL/B/$21/100"]
inventory = ["AAPL/0","GOOGL/75"]
return = ["AAPL/25","GOOGL/54"]
AAPL sells one accumulated whole share to the exchange. The dollar order equals 21 hundredths of GOOGL.

Constraints
1 <= inventory.length, orders.length <= 100000.
Inventory contains every ordered symbol exactly once and starts in [0,100).
Every dollar quantity converts exactly to a whole number of hundredths of a share.
All intermediate fixed-point values fit signed 64-bit integers.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Build a map from symbol to current inventory, keyed in the original order so you can emit rows at the end. For each order, split on '/', parse the quantity, and if it starts with $, convert dollars to hundredths with dollarCents * 100 / priceCents. The problem says the amount is given as a dollar figure like $21, so check whether you need to scale it into cents first, and test that against Example 2. Buy subtracts, sell adds. Then normalize into [0,100). The trap is language-level modulo: in many languages -150 % 100 gives -50, not 50. Use ((x % 100) + 100) % 100, or floor division. The exchange trades are implied, so you never store them. Another pitfall is rebuilding strings with the wrong symbol order. Keep an ordered list from the inventory input. Runtime is O(n + m), well within 100000 rows. If the dollar conversion or the negative modulo trips you during the live OA, StealthCoder is the hedge that covers it.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Fractional Share Inventory Flattening cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Robinhood's OA.

Robinhood reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Fractional Share Inventory Flattening FAQ

What's the trick in Fractional Share Inventory Flattening?+

Keep a hash map of symbol to hundredths, apply each order, then normalize into [0,100). The real trick is normalizing negatives correctly. A buy can push inventory below zero, and you need a true mathematical modulo, not the remainder operator your language gives you.

How do I handle the dollar quantities?+

If the quantity starts with $, strip it and parse the number, then compute dollarCents * 100 / priceCents. Check the scaling against Example 2 by hand: $21 at price 100 should give 21 hundredths. The constraints guarantee the division is exact, so integer math is safe.

Why does the negative modulo matter?+

Example 1 shows it. Inventory 0 minus 150 is -150, and the answer after flattening is 50. In C++, Java, and JavaScript, -150 % 100 is -50. Add 100 and mod again, or use floor division, to land in [0,100).

Do I need to track the whole shares traded at the exchange?+

No. The function only returns the final retained inventory rows. The exchange trades are just the amount you subtract or add to pull inventory back into range. Track the remainder and ignore the whole-share count.

How should I prepare in 48 hours for this kind of question?+

Practice fixed-point parsing, hash map updates, and modulo on negatives in your language of choice. Write this solution once end to end and run both examples. Also test an order that pushes inventory exactly to 100 or 0, since boundary values are where off-by-one bugs show up.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Robinhood.

OA at Robinhood?
Invisible during screen share
Get it