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 listMay 8, 2021 20:12Yuriy LyfenkoYuriy LyfenkoScore: 5,573Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 8, 2021 20:125,55893,056,13660,141,0001,002,0002,523,136
2May 8, 2021 20:125,55987,222,44560,149,0001,002,0002,387,968
3May 8, 2021 20:125,56086,863,03559,150,0002,005,0002,396,160
4May 8, 2021 20:125,56683,924,09959,224,0002,007,0002,396,160
5May 8, 2021 20:125,57391,944,53560,300,0001,005,0002,396,160
6May 8, 2021 20:125,57583,141,73261,326,00002,506,752
7May 8, 2021 20:125,57788,892,63760,341,0001,005,0002,400,256
8May 8, 2021 20:125,58382,717,59961,412,00002,400,256
9May 8, 2021 20:125,59282,497,12760,499,0001,008,0002,387,968