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 14:31E SequeiraE SequeiraScore: 300,642Success
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 14:31299,0943,324,220,1193,288,040,0001,998,0002,285,568
2Dec 14, 2024 14:31299,7533,325,466,9433,295,290,0001,998,0002,285,568
3Dec 14, 2024 14:31300,4223,330,320,3333,303,643,000999,0002,519,040
4Dec 14, 2024 14:31300,4233,333,146,0213,303,655,000999,0002,277,376
5Dec 14, 2024 14:31300,6423,335,323,8283,304,068,0002,998,0002,277,376
6Dec 14, 2024 14:31300,8963,339,537,0113,307,857,0001,998,0002,519,040
7Dec 14, 2024 14:31300,8993,342,338,3343,307,892,0001,998,0002,371,584
8Dec 14, 2024 14:31301,3863,342,732,7513,313,247,0001,998,0002,506,752
9Dec 14, 2024 14:31306,9583,403,301,4363,375,542,000999,0002,514,944