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 22, 2021 18:08Yuriy LyfenkoYuriy LyfenkoScore: 4,966Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2021 18:084,94777,115,15853,413,0001,007,0002,265,088
2May 22, 2021 18:084,94877,020,71453,416,0001,007,0002,396,160
3May 22, 2021 18:084,95475,434,33953,480,0001,009,0002,396,160
4May 22, 2021 18:084,95980,280,68554,549,00002,265,088
5May 22, 2021 18:084,96076,760,24154,564,00002,527,232
6May 22, 2021 18:084,96280,887,51754,578,00002,387,968
7May 22, 2021 18:084,96681,055,02653,620,0001,011,0002,265,088
8May 22, 2021 18:084,98679,284,15752,847,0001,994,0002,265,088
9May 22, 2021 18:085,05179,059,10754,548,0001,010,0002,392,064
10May 22, 2021 18:085,194118,685,61857,133,33502,236,416
11May 22, 2021 18:085,249116,078,68657,734,31402,240,512
12May 22, 2021 18:085,335125,718,93958,683,54002,228,224