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 3, 2025 18:31Aniruddha DebAniruddha DebScore: 15,184Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 3, 2025 18:3115,165195,057,163165,817,000998,0002,428,928
2Apr 3, 2025 18:3315,165192,104,670165,816,000998,0002,531,328
3Apr 3, 2025 18:3115,165196,553,661165,813,000998,0002,424,832
4Apr 3, 2025 18:3315,166196,512,392165,826,000998,0002,269,184
5Apr 3, 2025 18:3315,166195,507,850166,826,00002,428,928
6Apr 3, 2025 18:3115,172188,608,101164,889,0001,998,0002,531,328
7Apr 3, 2025 18:3115,176192,433,545165,933,000999,0002,269,184
8Apr 3, 2025 18:3315,178192,343,429165,960,000999,0002,437,120
9Apr 3, 2025 18:3315,180186,809,945164,976,0001,999,0002,424,832
10Apr 3, 2025 18:3115,184192,521,384165,019,0002,000,0002,269,184
11Apr 3, 2025 18:3315,184192,042,353165,019,0002,000,0002,531,328
12Apr 3, 2025 18:3315,184192,295,092166,021,0001,000,0002,433,024
13Apr 3, 2025 18:3115,185186,416,501165,036,0002,000,0002,531,328
14Apr 3, 2025 18:3315,185189,105,953166,031,0001,000,0002,531,328
15Apr 3, 2025 18:3315,185194,592,730166,033,0001,000,0002,433,024
16Apr 3, 2025 18:3115,186188,854,848165,045,0002,000,0002,269,184
17Apr 3, 2025 18:3115,193189,598,101166,126,0001,000,0002,433,024
18Apr 3, 2025 18:3115,213194,614,500166,345,0001,002,0002,531,328