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 listSep 3, 2024 18:56Yuriy LyfenkoYuriy LyfenkoScore: 4,420Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 3, 2024 18:564,40375,845,26547,429,0001,009,0002,289,664
2Sep 3, 2024 18:564,40670,523,47147,461,0001,009,0002,408,448
3Sep 3, 2024 18:564,40773,350,27947,470,0001,010,0002,277,376
4Sep 3, 2024 18:564,41370,803,82947,528,0001,011,0002,269,184
5Sep 3, 2024 18:564,41470,809,84547,545,0001,011,0002,289,664
6Sep 3, 2024 18:564,41974,891,36948,614,00002,392,064
7Sep 3, 2024 18:564,42072,385,15147,604,0001,012,0002,289,664
8Sep 3, 2024 18:564,42574,571,09947,657,0001,013,0002,289,664
9Sep 3, 2024 18:564,43677,052,30446,801,0001,991,0002,289,664
10Sep 3, 2024 18:564,43875,812,30046,824,0001,992,0002,527,232
11Sep 3, 2024 18:564,43877,330,52247,825,000996,0002,289,664
12Sep 3, 2024 18:564,44276,524,64247,845,0001,017,0002,289,664