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 18, 2024 23:43Joad NacerJoad NacerScore: 7,523Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 18, 2024 23:434,990131,436,68854,891,04602,273,280
2Apr 18, 2024 23:434,991121,988,56354,898,39502,265,088
3Apr 18, 2024 23:435,007120,931,24755,072,44602,265,088
4Apr 18, 2024 23:437,498108,751,84481,477,0001,005,0002,289,664
5Apr 18, 2024 23:437,514110,043,99881,642,0001,007,0002,289,664
6Apr 18, 2024 23:437,517113,743,17180,693,0001,992,0002,273,280
7Apr 18, 2024 23:437,523112,117,15181,757,000997,0002,289,664
8Apr 18, 2024 23:437,528117,818,31080,815,0001,995,0002,273,280
9Apr 18, 2024 23:437,529109,786,74180,822,0001,995,0002,289,664
10Apr 18, 2024 23:437,529108,548,50580,829,0001,995,0002,289,664
11Apr 18, 2024 23:437,530108,747,93581,830,000997,0002,289,664
12Apr 18, 2024 23:437,530107,303,24181,834,000997,0002,289,664