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 listDec 14, 2024 13:47E SequeiraE SequeiraScore: 409,414Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 14, 2024 13:47405,2754,518,661,1034,279,747,000178,281,0002,277,376
2Dec 14, 2024 13:47405,3914,517,054,5554,272,958,000186,344,0002,277,376
3Dec 14, 2024 13:47406,3494,534,910,1744,282,471,000187,364,0002,281,472
4Dec 14, 2024 13:47408,3934,549,486,0074,310,953,000181,366,0002,277,376
5Dec 14, 2024 13:47409,4144,563,184,1554,314,418,000189,141,0002,277,376
6Dec 14, 2024 13:47410,2584,598,912,3494,320,615,000192,226,0002,281,472
7Dec 14, 2024 13:47411,0434,588,461,6234,330,212,000191,258,0002,498,560
8Dec 14, 2024 13:47412,0914,619,875,8774,329,629,000203,371,0002,277,376
9Dec 14, 2024 13:47418,9694,714,680,9534,410,978,000197,685,0002,281,472