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 4, 2026 07:59Victor MerckléVictor MerckléError
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 4, 2026 08:03034,534,28725,358,0001,058,0002,424,832expected "405097162 ", got "405096906 "
2May 4, 2026 08:032,39534,442,03225,297,0001,057,0002,449,408
3May 4, 2026 08:032,39934,466,61225,332,0001,057,0002,416,640
4May 4, 2026 08:032,40534,507,28025,403,0001,062,0002,428,928
5May 4, 2026 08:032,40934,590,78025,439,0001,062,0002,445,312
6May 4, 2026 08:032,41134,685,76825,460,0001,070,0002,437,120
7May 4, 2026 08:032,42434,791,48625,600,0001,069,0002,428,928
8May 4, 2026 08:032,42634,799,57825,617,0001,072,0002,428,928
9May 4, 2026 08:032,48634,798,60226,257,0001,094,0002,433,024