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:33E SequeiraE SequeiraScore: 464,630Success
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:33463,5235,129,954,0625,071,773,00026,977,0002,437,120
2Dec 11, 2024 21:33464,0595,135,007,8815,056,674,00047,977,0002,342,912
3Dec 11, 2024 21:33464,5865,142,995,3555,069,476,00040,971,0002,392,064
4Dec 11, 2024 21:33464,6025,142,579,1885,072,647,00037,974,0002,392,064
5Dec 11, 2024 21:33464,6305,142,355,8405,067,952,00042,974,0002,531,328
6Dec 11, 2024 21:33464,9205,145,534,0825,080,138,00033,980,0002,531,328
7Dec 11, 2024 21:33464,9785,140,951,6215,075,770,00038,990,0002,531,328
8Dec 11, 2024 21:33465,9465,156,056,8385,085,427,00039,979,0002,416,640
9Dec 11, 2024 21:33467,5885,177,780,3305,096,505,00046,967,0002,363,392