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,968Success
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,95168,520,18742,455,0001,010,0002,396,160
2May 22, 2021 19:133,95263,667,99342,460,0001,010,0002,527,232
3May 22, 2021 19:133,95466,047,33042,485,0001,011,0002,265,088
4May 22, 2021 19:133,95567,133,08342,496,0001,011,0002,265,088
5May 22, 2021 19:133,96067,887,75343,557,00002,265,088
6May 22, 2021 19:133,96671,166,74742,607,0001,014,0002,265,088
7May 22, 2021 19:133,96871,431,00042,635,0001,015,0002,265,088
8May 22, 2021 19:133,97070,960,26042,653,0001,015,0002,392,064
9May 22, 2021 19:133,98773,210,30241,869,0001,993,0002,265,088
10May 22, 2021 19:134,028108,712,83144,304,20102,228,224
11May 22, 2021 19:134,028107,902,42044,304,48202,224,128
12May 22, 2021 19:134,045106,338,11744,498,57102,240,512