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:13Yuriy LyfenkoYuriy LyfenkoScore: 3,922Success
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:133,91270,713,51941,027,0002,001,0002,387,968
2May 22, 2021 19:133,91370,262,53141,039,0002,001,0002,400,256
3May 22, 2021 19:133,91868,351,20542,094,0001,002,0002,396,160
4May 22, 2021 19:133,91967,277,52942,102,0001,002,0002,265,088
5May 22, 2021 19:133,92170,780,95541,126,0002,006,0002,527,232
6May 22, 2021 19:133,92164,046,70742,133,0001,003,0002,265,088
7May 22, 2021 19:133,92269,362,37742,137,0001,003,0002,527,232
8May 22, 2021 19:133,92367,641,18642,149,0001,003,0002,527,232
9May 22, 2021 19:133,93166,107,37042,241,0001,005,0002,387,968
10May 22, 2021 19:134,091104,836,14645,005,86202,240,512
11May 22, 2021 19:134,103122,425,34345,132,57902,240,512
12May 22, 2021 19:134,115102,506,77645,265,88102,236,416