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 14, 2024 13:54E SequeiraE SequeiraScore: 322,117Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 14, 2024 13:54321,0283,557,355,6353,501,326,00029,985,0002,465,792
2Dec 14, 2024 13:54321,1513,559,436,4173,497,676,00034,986,0002,498,560
3Dec 14, 2024 13:54321,7293,566,577,6003,506,035,00032,981,0002,269,184
4Dec 14, 2024 13:54321,8093,569,314,0003,505,918,00033,979,0002,334,720
5Dec 14, 2024 13:54322,1173,569,991,1083,505,297,00037,992,0002,277,376
6Dec 14, 2024 13:54322,9983,583,298,5493,521,991,00030,982,0002,265,088
7Dec 14, 2024 13:54323,4573,587,582,5443,523,044,00034,980,0002,297,856
8Dec 14, 2024 13:54323,5503,586,960,2673,526,065,00032,981,0002,502,656
9Dec 14, 2024 13:54326,2063,621,071,2363,555,290,00032,974,0002,269,184