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 listJun 2, 2021 18:50Yuriy LyfenkoYuriy LyfenkoScore: 3,779Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 2, 2021 18:503,7571,065,725,70841,331,00002,523,136
2Jun 2, 2021 18:503,7681,067,933,96640,433,0001,010,0002,260,992
3Jun 2, 2021 18:503,7751,067,637,28640,510,0001,012,0002,527,232
4Jun 2, 2021 18:503,7751,072,236,55440,512,0001,012,0002,260,992
5Jun 2, 2021 18:503,7781,068,569,19239,578,0001,978,0002,523,136
6Jun 2, 2021 18:503,7781,067,106,42841,563,00002,260,992
7Jun 2, 2021 18:503,7791,074,515,15241,572,00002,523,136
8Jun 2, 2021 18:503,7891,067,480,13440,691,000992,0002,523,136
9Jun 2, 2021 18:503,8131,068,654,40840,942,000998,0002,519,040
10Jun 2, 2021 18:504,0141,102,100,65344,156,76802,224,128
11Jun 2, 2021 18:504,0161,095,152,80844,180,43102,240,512
12Jun 2, 2021 18:504,0301,106,614,78544,335,26302,240,512