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 listApr 13, 2025 17:38Wong ShouhaoWong ShouhaoScore: 603,289Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 13, 2025 17:38594,0616,565,041,9136,502,684,00031,983,0002,289,664
2Apr 13, 2025 17:38594,5326,571,997,4206,503,873,00035,977,0002,289,664
3Apr 13, 2025 17:38595,0356,573,908,4696,503,414,00041,976,0002,289,664
4Apr 13, 2025 17:38601,3766,643,022,3326,575,167,00039,970,0002,277,376
5Apr 13, 2025 17:38603,2896,671,287,7736,594,203,00041,975,0002,277,376
6Apr 13, 2025 17:38610,3476,740,459,4386,668,841,00044,978,0002,277,376
7Apr 13, 2025 17:38615,9836,806,389,0866,729,833,00045,978,0002,277,376
8Apr 13, 2025 17:38621,8216,869,194,0406,805,054,00034,974,0002,510,848
9Apr 13, 2025 17:38657,1047,261,054,1427,190,174,00037,969,0002,289,664