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:12E SequeiraE SequeiraScore: 317,635Success
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:12314,6963,489,762,7393,459,654,0001,998,0002,285,568
2Dec 14, 2024 14:12314,9513,502,080,3543,463,458,000999,0002,285,568
3Dec 14, 2024 14:12315,2243,500,747,7993,467,468,00002,519,040
4Dec 14, 2024 14:12315,3053,498,626,1383,467,352,000999,0002,285,568
5Dec 14, 2024 14:12317,6353,525,450,4063,491,982,0001,998,0002,277,376
6Dec 14, 2024 14:12317,7273,524,045,1153,493,001,0001,998,0002,277,376
7Dec 14, 2024 14:12318,7983,534,262,9463,504,785,0001,998,0002,359,296
8Dec 14, 2024 14:12318,9653,534,948,2303,507,612,000999,0002,277,376
9Dec 14, 2024 14:12319,1423,543,240,3523,509,559,000999,0002,277,376