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 listOct 7, 2026 01:21Karthik ReddyKarthik ReddyError
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Oct 7, 2026 01:210551,577,896540,029,0001,045,0002,113,536expected "404177733 ", got "usd199593 tx898340 ct89640 cf404276 ca404424 self91 selfnc77 selfrec91 hist 19909 19989 19923 19869 20145 19758 20220 19909 19994 19877 0 0 dig 0 9019 80754 808567 0 0 "
2Oct 7, 2026 01:210551,504,574540,004,0001,097,0002,113,536expected "404328328 ", got "usd199813 tx898850 ct89444 cf405223 ca404183 self94 selfnc90 selfrec93 hist 20180 20017 19595 19753 20219 20248 19982 20099 19797 19923 0 0 dig 0 9059 80986 808805 0 0 "
3Oct 7, 2026 01:210552,768,478541,204,0001,112,0002,113,536expected "406008698 ", got "usd200437 tx903091 ct90242 cf406091 ca406758 self75 selfnc64 selfrec75 hist 20004 20314 20053 19767 19813 20177 19707 20161 20105 20336 0 0 dig 0 9026 81801 812264 0 0 "