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 06:14Yuriy LyfenkoYuriy LyfenkoScore: 11,496Success
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 06:1411,493148,591,344124,413,0002,006,0002,523,136
2May 8, 2021 06:1411,493155,222,890126,419,00002,330,624
3May 8, 2021 06:1411,495148,563,856125,443,0001,003,0002,330,624
4May 8, 2021 06:1411,496145,259,886123,443,0003,010,0002,322,432
5May 8, 2021 06:1411,496148,556,323124,447,0002,007,0002,330,624
6May 8, 2021 06:1411,496150,607,040124,452,0002,007,0002,531,328
7May 8, 2021 06:1411,497154,144,320125,467,0001,003,0002,334,720
8May 8, 2021 06:1411,499147,828,470124,479,0002,007,0002,334,720
9May 8, 2021 06:1411,508157,085,665124,577,0002,009,0002,314,240