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 2, 2021 16:10Andrey TsvetkovAndrey TsvetkovScore: 12,124Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 16:1012,075159,748,584106,860,00025,966,0002,334,720
2May 2, 2021 16:1012,077164,752,370103,663,00029,186,0002,461,696
3May 2, 2021 16:1012,098159,881,898106,064,00027,016,0002,457,600
4May 2, 2021 16:1012,099158,784,794102,066,00031,020,0002,453,504
5May 2, 2021 16:1012,124162,977,497106,294,00027,075,0002,334,720
6May 2, 2021 16:1012,132152,121,409107,364,00026,088,0002,449,408
7May 2, 2021 16:1012,139161,926,318108,427,00025,099,0002,334,720
8May 2, 2021 16:1012,165161,257,380100,863,00032,955,0002,334,720
9May 2, 2021 16:1012,167159,655,396105,871,00027,965,0002,465,792