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 16, 2021 21:28Andrey TsvetkovAndrey TsvetkovScore: 12,369Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 16, 2021 21:2812,306159,783,224135,369,00002,330,624
2Jun 16, 2021 21:2812,331162,653,132134,628,0001,012,0002,330,624
3Jun 16, 2021 21:2812,346165,788,016135,811,00002,330,624
4Jun 16, 2021 21:2812,347206,294,147135,821,63202,314,240
5Jun 16, 2021 21:2812,362196,453,760135,984,71502,314,240
6Jun 16, 2021 21:2812,365170,757,447133,012,0003,000,0002,330,624
7Jun 16, 2021 21:2812,369163,596,822133,057,0003,001,0002,330,624
8Jun 16, 2021 21:2812,373156,106,175134,092,0002,016,0002,330,624
9Jun 16, 2021 21:2812,393190,997,844136,324,89302,306,048
10Jun 16, 2021 21:2812,407155,339,343136,474,00002,310,144
11Jun 16, 2021 21:2812,452166,477,754134,970,0001,999,0002,514,944
12Jun 16, 2021 21:2812,467159,114,510134,135,0003,003,0002,330,624