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 25, 2021 14:13Andrei GrazhdankovAndrei GrazhdankovScore: 130,137Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 25, 2021 14:15129,6831,471,649,4631,426,512,70702,289,664
2May 25, 2021 14:15129,8531,483,444,7081,428,380,65602,256,896
3May 25, 2021 14:13129,8911,475,711,5171,428,805,03202,195,456
4May 26, 2021 07:33129,9891,479,145,2021,429,877,30302,301,952
5May 26, 2021 07:33130,1371,483,928,4601,431,509,64502,293,760
6May 25, 2021 14:13130,2241,499,856,2261,432,465,02702,310,144
7May 25, 2021 14:13130,2621,491,532,2751,432,883,51302,297,856
8May 25, 2021 14:15130,2671,507,136,7281,432,941,69802,228,224
9May 26, 2021 07:33131,5701,513,579,6651,447,265,61102,310,144