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 listJun 17, 2021 08:49Andrey TsvetkovAndrey TsvetkovScore: 12,236Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 17, 2021 08:4912,218161,854,015132,395,0002,005,0002,330,624
2Jun 17, 2021 08:4912,220155,666,632133,420,0001,003,0002,375,680
3Jun 17, 2021 08:4912,223191,116,555134,449,91102,179,072
4Jun 17, 2021 08:4912,231157,716,497133,533,0001,004,0002,330,624
5Jun 17, 2021 08:4912,232158,983,481133,552,0001,004,0002,371,584
6Jun 17, 2021 08:4912,234160,852,414132,569,0002,008,0002,502,656
7Jun 17, 2021 08:4912,236163,810,292133,595,0001,004,0002,330,624
8Jun 17, 2021 08:4912,244191,742,613134,688,47502,191,360
9Jun 17, 2021 08:4912,249211,728,460134,744,10802,306,048
10Jun 17, 2021 08:4912,259161,691,528131,856,0002,996,0002,330,624
11Jun 17, 2021 08:4912,259156,955,986133,846,0001,006,0002,330,624
12Jun 17, 2021 08:4912,274164,674,284133,012,0002,000,0002,330,624