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 listDec 11, 2024 21:07E SequeiraE SequeiraScore: 467,618Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 11, 2024 21:07467,2205,170,850,7175,101,445,00037,973,0002,334,720
2Dec 11, 2024 21:07467,5055,171,814,5215,109,581,00032,977,0002,338,816
3Dec 11, 2024 21:07467,5475,176,595,8855,110,036,00032,980,0002,322,432
4Dec 11, 2024 21:07467,6035,176,373,7195,104,664,00038,974,0002,281,472
5Dec 11, 2024 21:07467,6185,175,107,0045,106,827,00036,969,0002,322,432
6Dec 11, 2024 21:07467,7085,172,735,3985,109,812,00034,978,0002,289,664
7Dec 11, 2024 21:07468,1275,176,217,5255,115,417,00033,982,0002,334,720
8Dec 11, 2024 21:07468,2115,180,050,8135,115,344,00034,975,0002,314,240
9Dec 11, 2024 21:07468,4155,186,354,2245,126,586,00025,982,0002,334,720