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 22, 2021 19:21Yuriy LyfenkoYuriy LyfenkoScore: 4,008Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2021 19:213,92572,679,58541,169,0002,008,0002,396,160
2May 22, 2021 19:213,99995,800,49943,988,31902,240,512
3May 22, 2021 19:214,00073,207,46542,003,0002,000,0002,506,752
4May 22, 2021 19:214,00373,946,30243,038,0001,000,0002,523,136
5May 22, 2021 19:214,00669,640,35042,061,0002,002,0002,392,064
6May 22, 2021 19:214,00777,778,86343,075,0001,001,0002,265,088
7May 22, 2021 19:214,00868,204,35242,083,0002,003,0002,523,136
8May 22, 2021 19:214,01069,994,27143,105,0001,002,0002,269,184
9May 22, 2021 19:214,02269,193,58343,232,0001,005,0002,527,232
10May 22, 2021 19:214,024104,644,30344,260,22602,232,320
11May 22, 2021 19:214,02869,210,73342,290,0002,013,0002,494,464
12May 22, 2021 19:214,048116,036,69944,527,07602,240,512