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 20, 2024 17:39Joad NacerJoad NacerScore: 5,054Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 20, 2024 17:395,04379,764,33654,469,0001,008,0002,289,664
2Apr 20, 2024 17:395,04485,684,43454,472,0001,008,0002,277,376
3Apr 20, 2024 17:395,04983,236,38654,529,0001,009,0002,289,664
4Apr 20, 2024 17:395,05083,679,57454,536,0001,009,0002,289,664
5Apr 20, 2024 17:395,05384,851,24654,568,0001,010,0002,289,664
6Apr 20, 2024 17:395,05487,448,12355,592,00002,289,664
7Apr 20, 2024 17:395,05484,285,88354,583,0001,010,0002,289,664
8Apr 20, 2024 17:395,05685,652,64055,613,00002,289,664
9Apr 20, 2024 17:395,05987,180,51555,647,00002,277,376
10Apr 20, 2024 17:396,478133,100,87371,253,29802,273,280
11Apr 20, 2024 17:396,481129,069,62271,286,45602,273,280
12Apr 20, 2024 17:396,496130,894,73371,451,01202,265,088