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 20, 2021 13:04Andrei GrazhdankovAndrei GrazhdankovError
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 19:0700000no run stats recorded
2May 25, 2021 14:03539,3125,979,917,9455,932,437,46902,211,840
3May 25, 2021 13:49541,0625,992,075,9005,951,684,82802,215,936
4May 20, 2021 13:04541,1626,012,968,9815,952,783,24502,232,320
5May 25, 2021 14:03541,6066,039,597,5155,957,665,45602,285,568
6May 25, 2021 13:49541,9046,022,382,2695,960,948,04102,314,240
7May 25, 2021 13:49543,3956,027,761,9045,977,341,24002,199,552
8May 20, 2021 13:04546,8696,079,034,7896,015,554,70802,220,032
9May 25, 2021 14:03553,6016,139,940,8016,089,615,34202,211,840
10May 20, 2021 13:04566,3006,284,317,3676,229,302,44202,220,032