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 26, 2021 11:46Andrei GrazhdankovAndrei GrazhdankovScore: 129,339Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 26, 2021 07:50128,7161,459,523,6781,415,878,67102,297,856
2May 26, 2021 11:46128,7691,456,016,9011,416,454,35902,215,936
3May 26, 2021 07:51128,8241,475,557,3641,417,067,58702,199,552
4May 26, 2021 07:51129,0021,492,175,5941,419,017,11102,318,336
5May 26, 2021 07:50129,3391,495,386,7651,422,725,83802,301,952
6May 26, 2021 11:46129,3641,467,550,1691,423,001,60102,228,224
7May 26, 2021 11:46129,3801,494,147,9651,423,176,68602,215,936
8May 26, 2021 07:50129,5721,471,681,0131,425,287,94702,310,144
9May 26, 2021 07:51129,8391,476,041,5771,428,230,77102,289,664