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 15:41Yuriy LyfenkoYuriy LyfenkoScore: 11,609Success
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 15:4111,600156,493,914123,586,0004,019,0002,330,624
2May 8, 2021 15:4111,603152,786,177127,638,00002,330,624
3May 8, 2021 15:4111,608158,094,922126,685,0001,005,0002,531,328
4May 8, 2021 15:4111,608151,745,489125,682,0002,010,0002,527,232
5May 8, 2021 15:4111,609157,093,588126,689,0001,005,0002,330,624
6May 8, 2021 15:4111,620158,537,935126,822,000998,0002,531,328
7May 8, 2021 15:4111,620152,113,628126,823,000998,0002,330,624
8May 8, 2021 15:4111,622153,905,216124,843,0002,996,0002,330,624
9May 8, 2021 15:4111,638156,217,352126,021,0002,000,0002,330,624