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, 2021 13:31Yuriy LyfenkoYuriy LyfenkoScore: 5,622Success
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, 2021 13:315,60387,046,01661,637,00002,506,752
2May 4, 2021 13:315,60786,404,78159,659,0002,022,0002,396,160
3May 4, 2021 13:315,61187,579,53561,726,00002,260,992
4May 4, 2021 13:315,61590,044,12961,762,00002,392,064
5May 4, 2021 13:315,62293,422,17859,844,0001,994,0002,523,136
6May 4, 2021 13:315,62293,667,68760,844,000997,0002,260,992
7May 4, 2021 13:315,62390,247,78059,861,0001,995,0002,392,064
8May 4, 2021 13:315,62487,979,09560,871,000997,0002,523,136
9May 4, 2021 13:315,63786,517,77560,006,0002,000,0002,387,968