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 listSep 2, 2025 06:13Alex KentAlex KentScore: 6,239Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 2, 2025 06:136,21791,188,86967,377,0001,005,0002,285,568
2Sep 2, 2025 06:136,22694,550,62767,481,0001,007,0002,285,568
3Sep 2, 2025 06:136,23695,318,17867,592,0001,008,0002,260,992
4Sep 2, 2025 06:136,23893,956,30767,605,0001,009,0002,379,776
5Sep 2, 2025 06:136,23995,403,83867,622,0001,009,0002,285,568
6Sep 2, 2025 06:136,24393,817,54567,669,0001,009,0002,523,136
7Sep 2, 2025 06:136,24495,255,29767,671,0001,010,0002,519,040
8Sep 2, 2025 06:136,26492,071,64066,912,0001,997,0002,285,568
9Sep 2, 2025 06:136,27094,132,98766,966,0001,999,0002,523,136