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 listAug 22, 2024 18:16Andrey LikhachevAndrey LikhachevScore: 7,208Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 22, 2024 18:167,175108,302,22476,926,0001,998,0002,289,664
2Aug 22, 2024 18:167,184103,884,47878,025,0001,000,0002,289,664
3Aug 22, 2024 18:167,196107,099,56277,154,0002,004,0002,367,488
4Aug 22, 2024 18:167,198101,443,40377,170,0002,004,0002,289,664
5Aug 22, 2024 18:167,19899,384,34978,181,0001,002,0002,359,296
6Aug 22, 2024 18:167,199108,637,39277,180,0002,004,0002,289,664
7Aug 22, 2024 18:167,208105,301,50579,292,00002,371,584
8Aug 22, 2024 18:167,213104,250,50779,340,00002,289,664
9Aug 22, 2024 18:167,220101,770,80378,413,0001,005,0002,289,664
10Aug 22, 2024 18:167,282154,012,76080,100,05002,342,912
11Aug 22, 2024 18:167,282139,374,35980,103,57702,203,648
12Aug 22, 2024 18:167,298136,638,87980,278,86402,203,648