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 20, 2021 14:42Andrey TsvetkovAndrey TsvetkovScore: 11,900Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 20, 2021 14:4211,876187,254,579130,634,92802,183,168
2Jun 20, 2021 14:4211,892156,559,563128,817,0001,997,0002,510,848
3Jun 20, 2021 14:4211,893157,559,720129,826,000998,0002,326,528
4Jun 20, 2021 14:4211,897156,824,509127,866,0002,996,0002,322,432
5Jun 20, 2021 14:4211,897155,783,805126,868,0003,995,0002,498,560
6Jun 20, 2021 14:4211,900197,065,437130,898,63402,191,360
7Jun 20, 2021 14:4211,900160,027,259128,903,0001,998,0002,510,848
8Jun 20, 2021 14:4211,901159,182,901127,909,0002,997,0002,506,752
9Jun 20, 2021 14:4211,901160,442,748127,915,0002,998,0002,326,528
10Jun 20, 2021 14:4211,908157,032,256128,984,0001,999,0002,322,432
11Jun 20, 2021 14:4211,918155,768,169127,096,0004,003,0002,502,656
12Jun 20, 2021 14:4211,947189,772,507131,418,43402,179,072