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 listMay 7, 2025 20:54Aleksey ShvetsAleksey ShvetsScore: 120,487Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 7, 2025 20:54120,1611,350,259,1471,315,776,0005,998,0002,433,024
2May 7, 2025 20:54120,3641,351,051,3101,318,006,0005,995,0002,433,024
3May 7, 2025 20:54120,4151,353,998,5971,316,579,0007,991,0002,445,312
4May 7, 2025 20:54120,4541,355,821,5341,320,003,0004,996,0002,289,664
5May 7, 2025 20:54120,4871,350,302,0891,322,358,0003,000,0002,428,928
6May 7, 2025 20:54120,8031,354,293,3371,324,833,0003,996,0002,437,120
7May 7, 2025 20:54121,6321,362,645,5081,330,963,0006,994,0002,424,832
8May 7, 2025 20:54122,7371,380,914,8021,345,109,0004,996,0002,514,944
9May 7, 2025 20:54123,1941,385,635,1531,354,137,000999,0002,371,584