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 listNov 10, 2024 07:32E SequeiraE SequeiraScore: 504,952Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 10, 2024 07:32501,5645,544,474,0155,517,199,00002,535,424
2Nov 10, 2024 07:32502,1265,558,008,0975,521,388,0001,999,0002,531,328
3Nov 10, 2024 07:32502,9705,570,991,0735,531,666,000999,0002,281,472
4Nov 10, 2024 07:32504,7025,583,813,2905,549,727,0001,998,0002,281,472
5Nov 10, 2024 07:32504,9525,583,461,2695,553,472,000999,0002,281,472
6Nov 10, 2024 07:32510,5245,643,458,8895,614,761,000999,0002,289,664
7Nov 10, 2024 07:32510,7925,650,800,1355,617,708,000999,0002,281,472
8Nov 10, 2024 07:32511,2325,652,982,7495,621,557,0001,999,0002,281,472
9Nov 10, 2024 07:32515,3605,700,361,4015,666,967,0001,998,0002,281,472