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:19Yuriy LyfenkoYuriy LyfenkoScore: 4,003Success
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:193,93965,619,93342,323,0001,007,0002,265,088
2May 22, 2021 19:193,94169,965,67542,345,0001,008,0002,265,088
3May 22, 2021 19:193,98971,655,08941,884,0001,994,0002,527,232
4May 22, 2021 19:193,99569,868,07842,947,000998,0002,265,088
5May 22, 2021 19:193,99771,955,10142,965,000999,0002,523,136
6May 22, 2021 19:193,99968,511,04942,987,000999,0002,265,088
7May 22, 2021 19:194,00370,652,80142,030,0002,001,0002,265,088
8May 22, 2021 19:194,00568,033,41243,058,0001,001,0002,527,232
9May 22, 2021 19:194,01172,104,54542,118,0002,005,0002,527,232
10May 22, 2021 19:194,028112,454,51444,304,30902,228,224
11May 22, 2021 19:194,033116,610,02444,361,40702,236,416
12May 22, 2021 19:194,049110,490,15744,542,83502,232,320