Capital Gains Tax Calculator
Optiver interview questions · Hard · Coding round · 7 tests
The input is a list of stock trades already ordered by time. Every trade is a string array shaped
like [timestamp, type, shares, price], in which:
typeholds either"buy"or"sell"sharesis a string containing a whole-number share countpriceis a string containing the price paid or received per share
Apply FIFO cost basis: shares that are sold are taken from the earliest buy lots that still have shares remaining.
For every sell trade:
Run your code with Ctrl+Enter to see results.