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:09Yuriy LyfenkoYuriy LyfenkoScore: 4,959Success
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:094,94277,989,09453,355,0001,006,0002,265,088
2May 22, 2021 18:094,95076,898,15553,439,0001,008,0002,392,064
3May 22, 2021 18:094,95078,725,22054,455,00002,527,232
4May 22, 2021 18:094,95477,068,97954,490,00002,269,184
5May 22, 2021 18:094,95774,219,12453,515,0001,009,0002,387,968
6May 22, 2021 18:094,95882,981,98854,537,00002,265,088
7May 22, 2021 18:094,95975,511,80854,547,00002,392,064
8May 22, 2021 18:094,96686,039,55354,624,00002,527,232
9May 22, 2021 18:094,98283,728,26952,813,0001,992,0002,478,080
10May 22, 2021 18:095,182119,862,57557,003,73402,244,608
11May 22, 2021 18:095,183118,894,11657,017,88702,232,320
12May 22, 2021 18:095,200116,281,79857,205,04102,228,224