Parse JSON Sergey Svistunov

Compute the total amount of non-canceled external USD transactions from a stream of JSON records as fast as possible.

Input: 1 000 000 JSON records on STDIN, one per line. Each record has the following structure:

{
    "user_id": 0,
    "currency": "USD",
    "transactions": [
        {
            "amount": 0,
            "to_user_id": 0,
            "canceled": false
        }
    ]
}
Field Constraints
user_id Integer, max 10 000
currency One of "GBP", "USD", "RUB", "JPY", "CHF"
transactions Array, max 10 elements
amount Integer, max 1000
canceled Boolean; may be omitted when false

Field order is not guaranteed within any object.

Output: The total amount of all transactions where:

  • record.currency == "USD"
  • transaction.to_user_id != record.user_id (external)
  • transaction.canceled is false or absent
Back to listOct 7, 2026 01:07Karthik ReddyKarthik ReddyError
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 7, 2026 01:070540,190,506528,512,0001,099,0002,113,536expected "405628390 ", got "sz267144584 L1000000 max558 sp27047551 canc2473883 true451623 empty100193 GBP200029 USD200063 RUB199839 JPY199553 CHF200516 fk332975/333900/333125 F:{"currency":_"USD",_"transactions":_[{"canceled":_false,_"amount":_789,_"to...
2Oct 7, 2026 01:070540,346,190528,709,0001,148,0002,113,536expected "402773674 ", got "sz267090395 L1000000 max558 sp27041648 canc2473539 true450199 empty100226 GBP200071 USD199643 RUB200503 JPY199710 CHF200073 fk332843/333716/333441 F:{"user_id":_9135,_"transactions":_[{"to_user_id":_9236,_"amount":_789},_{"t...
3Oct 7, 2026 01:070539,961,833528,221,0001,263,0002,113,536expected "404987825 ", got "sz267078542 L1000000 max558 sp27039976 canc2473795 true449157 empty100042 GBP199636 USD200339 RUB199705 JPY200351 CHF199969 fk332861/333291/333848 F:{"transactions":_[{"amount":_863,_"to_user_id":_4278},_{"to_user_id":_3247,...