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 1, 2021 13:55Yurkov AlekseyYurkov AlekseyScore: 10,992Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2021 13:5510,984148,701,568118,826,0001,997,0002,277,376
2May 1, 2021 13:5510,984146,176,614118,831,0001,997,0002,523,136
3May 1, 2021 13:5510,986151,280,676117,845,0002,996,0002,527,232
4May 1, 2021 13:5510,986149,012,335119,840,0001,007,0002,277,376
5May 1, 2021 13:5510,992143,708,301117,911,0002,997,0002,277,376
6May 1, 2021 13:5510,996143,599,487118,953,0001,999,0002,277,376
7May 1, 2021 13:5511,001141,873,157119,011,0002,000,0002,355,200
8May 1, 2021 13:5511,008146,336,073118,086,0003,002,0002,277,376
9May 1, 2021 13:5511,018146,427,750119,190,0002,003,0002,269,184