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 listFeb 20, 2025 19:24korsajankorsajanScore: 461,130Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Feb 20, 2025 19:24459,8805,085,820,8084,965,761,00092,920,0002,318,336
2Feb 20, 2025 19:24460,4485,099,163,3314,950,003,000114,930,0002,371,584
3Feb 20, 2025 19:24460,4685,095,858,0214,955,214,000109,938,0002,510,848
4Feb 20, 2025 19:24461,1275,103,545,5174,977,462,00094,932,0002,297,856
5Feb 20, 2025 19:24461,1305,105,269,8944,973,503,00098,930,0002,289,664
6Feb 20, 2025 19:24461,4715,109,937,4094,981,276,00094,910,0002,322,432
7Feb 20, 2025 19:24461,5795,105,562,2384,961,453,000115,917,0002,392,064
8Feb 20, 2025 19:24461,8125,108,467,8634,980,997,00098,940,0002,293,760
9Feb 20, 2025 19:24462,1555,119,141,4154,974,794,000108,907,0002,473,984