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 listApr 19, 2025 16:20Aleksey ShvetsAleksey ShvetsScore: 479,294Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 19, 2025 16:20478,4505,298,113,9335,143,063,000119,884,0002,531,328
2Apr 19, 2025 16:20478,4515,297,338,9645,164,033,00098,924,0002,310,144
3Apr 19, 2025 16:20478,4535,295,217,0135,169,054,00093,928,0002,408,448
4Apr 19, 2025 16:20478,9375,295,689,9375,159,382,000108,923,0002,539,520
5Apr 19, 2025 16:20479,2945,308,720,3265,182,314,00089,918,0002,310,144
6Apr 19, 2025 16:20479,3615,300,414,7915,177,050,00095,926,0002,334,720
7Apr 19, 2025 16:20480,3805,393,436,9925,179,358,000104,825,0002,338,816
8Apr 19, 2025 16:20481,9555,333,773,4525,204,569,00096,936,0002,351,104
9Apr 19, 2025 16:20484,6585,362,840,6995,226,317,000104,926,0002,310,144