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 19, 2021 19:06Yuriy LyfenkoYuriy LyfenkoScore: 5,629Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 19, 2021 19:065,5891,354,620,72460,470,0001,007,0002,527,232
2May 19, 2021 19:065,5974,242,405,33660,559,0001,009,0002,523,136
3May 19, 2021 19:065,597649,958,28460,578,000993,0002,269,184
4May 19, 2021 19:065,5992,827,469,68457,621,0003,973,0002,269,184
5May 19, 2021 19:065,6161,897,559,90560,784,000996,0002,523,136
6May 19, 2021 19:065,6201,576,576,38059,830,0001,994,0002,265,088
7May 19, 2021 19:065,6292,095,578,98058,919,0002,995,0002,265,088
8May 19, 2021 19:065,6314,955,248,68659,940,0001,998,0002,265,088
9May 19, 2021 19:065,7102,250,587,91261,799,0001,013,0002,260,992
10May 19, 2021 19:065,8774,726,815,59664,647,96802,301,952
11May 19, 2021 19:065,888712,383,36364,770,67202,252,800
12May 19, 2021 19:065,8964,483,215,80064,855,79102,240,512