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 listDec 16, 2024 23:12Mikhail ShirokovMikhail ShirokovScore: 469,183Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 16, 2024 23:12464,8335,141,660,6125,112,164,000999,0002,273,280
2Dec 16, 2024 23:12466,3485,156,101,1335,125,835,0003,997,0002,367,488
3Dec 16, 2024 23:12467,1465,168,745,6875,136,603,0001,998,0002,277,376
4Dec 16, 2024 23:12467,3635,172,200,0155,139,000,0001,998,0002,273,280
5Dec 16, 2024 23:12469,1835,185,683,9235,159,013,0001,998,0002,273,280
6Dec 16, 2024 23:12472,3335,220,456,5565,193,661,0001,999,0002,273,280
7Dec 16, 2024 23:12472,7625,233,655,3985,198,389,0001,998,0002,277,376
8Dec 16, 2024 23:12477,2675,283,791,2905,247,943,0001,998,0002,273,280
9Dec 16, 2024 23:12481,4415,327,640,5695,293,852,0001,998,0002,273,280