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 8, 2021 20:11Yuriy LyfenkoYuriy LyfenkoScore: 5,571Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 8, 2021 20:115,55984,878,47460,144,0001,002,0002,523,136
2May 8, 2021 20:115,56184,317,55659,164,0002,005,0002,396,160
3May 8, 2021 20:115,56986,122,84959,246,0002,008,0002,392,064
4May 8, 2021 20:115,57089,909,85461,270,00002,506,752
5May 8, 2021 20:115,57185,986,30461,284,00002,383,872
6May 8, 2021 20:115,57481,764,52860,304,0001,005,0002,523,136
7May 8, 2021 20:115,58082,512,51661,378,00002,396,160
8May 8, 2021 20:115,58384,166,00861,412,00002,392,064
9May 8, 2021 20:115,58787,672,91161,458,00002,396,160