← Back
00:00

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:

  • type holds either "buy" or "sell"
  • shares is a string containing a whole-number share count
  • price is 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:

Idle