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 19, 2024 01:08Joad NacerJoad NacerScore: 6,507Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 19, 2024 01:084,890108,353,99853,790,87102,260,992
2Apr 19, 2024 01:084,905111,378,14053,954,34002,277,376
3Apr 19, 2024 01:084,909122,024,82253,996,41102,269,184
4Apr 19, 2024 01:086,47797,657,27269,237,0002,006,0002,527,232
5Apr 19, 2024 01:086,49394,217,79771,420,00002,289,664
6Apr 19, 2024 01:086,502103,012,97970,517,0001,007,0002,527,232
7Apr 19, 2024 01:086,50793,473,82671,576,00002,289,664
8Apr 19, 2024 01:086,51297,924,53770,622,0001,008,0002,289,664
9Apr 19, 2024 01:086,51699,240,56870,662,0001,009,0002,527,232
10Apr 19, 2024 01:086,51697,452,86071,679,00002,269,184
11Apr 19, 2024 01:086,52898,782,81769,811,0001,994,0002,289,664
12Apr 19, 2024 01:086,55798,172,72670,123,0002,003,0002,289,664