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 4, 2024 17:40Joad NacerJoad NacerScore: 7,598Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 4, 2024 17:404,978127,359,23754,759,93202,269,184
2Jun 4, 2024 17:404,979112,222,11154,763,87902,260,992
3Jun 4, 2024 17:404,981121,655,90954,786,83402,269,184
4Jun 4, 2024 17:407,578108,881,90883,354,00002,277,376
5Jun 4, 2024 17:407,587105,713,35382,456,0001,005,0002,277,376
6Jun 4, 2024 17:407,593103,437,94782,519,0001,006,0002,277,376
7Jun 4, 2024 17:407,598110,646,22982,572,0001,006,0002,277,376
8Jun 4, 2024 17:407,599115,696,44480,571,0003,021,0002,277,376
9Jun 4, 2024 17:407,602114,751,64483,618,00002,523,136
10Jun 4, 2024 17:407,605106,581,49681,660,0001,991,0002,273,280
11Jun 4, 2024 17:407,621109,964,32579,836,0003,991,0002,273,280
12Jun 4, 2024 17:407,627109,420,07881,904,0001,997,0002,531,328