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 09:22Andrey TsvetkovAndrey TsvetkovScore: 13,692Success
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 09:2213,679214,978,752150,472,38202,187,264
2Jun 17, 2021 09:2213,679170,302,679148,458,0002,006,0002,306,048
3Jun 17, 2021 09:2213,679174,617,210148,466,0002,006,0002,330,624
4Jun 17, 2021 09:2213,680170,815,791148,473,0002,006,0002,514,944
5Jun 17, 2021 09:2213,680171,927,181148,475,0002,006,0002,510,848
6Jun 17, 2021 09:2213,686205,475,656150,541,91802,191,360
7Jun 17, 2021 09:2213,692175,878,172148,606,0002,008,0002,330,624
8Jun 17, 2021 09:2213,697176,807,873148,662,0002,008,0002,502,656
9Jun 17, 2021 09:2213,709177,296,004147,805,0002,996,0002,330,624
10Jun 17, 2021 09:2213,712181,129,938149,839,000998,0002,330,624
11Jun 17, 2021 09:2213,723179,402,724148,959,0001,999,0002,330,624
12Jun 17, 2021 09:2213,731209,065,984151,036,80002,179,072