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 listDec 14, 2024 13:41E SequeiraE SequeiraScore: 422,663Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 14, 2024 13:41421,4144,693,351,2954,440,252,000195,307,0002,277,376
2Dec 14, 2024 13:41421,9894,707,491,2574,445,777,000196,107,0002,490,368
3Dec 14, 2024 13:41422,3864,708,587,3924,452,897,000193,344,0002,490,368
4Dec 14, 2024 13:41422,4274,714,016,3774,449,386,000197,307,0002,498,560
5Dec 14, 2024 13:41422,6634,713,710,4984,455,031,000194,260,0002,281,472
6Dec 14, 2024 13:41423,6434,728,327,7864,466,776,000193,297,0002,502,656
7Dec 14, 2024 13:41426,3514,748,641,9464,497,607,000192,256,0002,277,376
8Dec 14, 2024 13:41428,1454,769,257,3694,506,302,000203,291,0002,502,656
9Dec 14, 2024 13:41440,5974,912,623,5304,664,191,000182,381,0002,498,560