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 8, 2021 15:45Yuriy LyfenkoYuriy LyfenkoScore: 10,380Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 8, 2021 15:4510,368141,055,587112,052,0002,000,0002,519,040
2May 8, 2021 15:4510,369140,071,303112,058,0002,001,0002,334,720
3May 8, 2021 15:4510,376135,394,785112,138,0002,002,0002,392,064
4May 8, 2021 15:4510,377136,899,405112,141,0002,002,0002,523,136
5May 8, 2021 15:4510,380139,232,534111,176,0003,004,0002,531,328
6May 8, 2021 15:4510,380137,577,941113,180,0001,001,0002,330,624
7May 8, 2021 15:4510,383137,165,505111,205,0003,005,0002,330,624
8May 8, 2021 15:4510,388144,542,998111,266,0003,007,0002,535,424
9May 8, 2021 15:4510,392139,005,180111,300,0003,008,0002,310,144