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 listNov 23, 2024 16:37E SequeiraE SequeiraScore: 479,292Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 23, 2024 16:37475,8295,265,016,8165,203,134,00030,982,0002,293,760
2Nov 23, 2024 16:37477,1285,277,275,3975,220,428,00027,980,0002,441,216
3Nov 23, 2024 16:37477,4815,286,512,8345,218,311,00033,975,0002,293,760
4Nov 23, 2024 16:37478,4145,287,242,6215,230,572,00031,979,0002,441,216
5Nov 23, 2024 16:37479,2925,306,810,9385,241,228,00030,983,0002,514,944
6Nov 23, 2024 16:37479,7195,306,573,6435,246,922,00029,982,0002,293,760
7Nov 23, 2024 16:37481,9675,338,267,2385,270,654,00030,980,0002,449,408
8Nov 23, 2024 16:37497,2935,505,007,3745,442,242,00027,985,0002,293,760
9Nov 23, 2024 16:37518,9155,738,473,3495,676,083,00031,983,0002,277,376