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 23, 2024 17:42Joad NacerJoad NacerScore: 7,713Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 23, 2024 17:424,996127,022,78254,953,54202,273,280
2Apr 23, 2024 17:425,002118,546,17055,020,70102,273,280
3Apr 23, 2024 17:425,009118,253,77655,100,90102,265,088
4Apr 23, 2024 17:427,690118,982,16083,588,0001,007,0002,273,280
5Apr 23, 2024 17:427,712115,245,41283,831,000997,0002,273,280
6Apr 23, 2024 17:427,713112,194,92182,845,0001,996,0002,289,664
7Apr 23, 2024 17:427,713114,884,15584,846,00002,289,664
8Apr 23, 2024 17:427,714106,965,26183,858,000998,0002,289,664
9Apr 23, 2024 17:427,720108,013,19282,917,0001,998,0002,289,664
10Apr 23, 2024 17:427,726110,313,81582,982,0001,999,0002,289,664
11Apr 23, 2024 17:427,735107,734,45983,087,0002,002,0002,289,664
12Apr 23, 2024 17:427,738113,717,15185,116,00002,269,184