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 00:03Joad NacerJoad NacerScore: 7,903Success
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 00:034,797119,475,19352,769,95502,273,280
2Apr 19, 2024 00:034,809127,673,20752,894,04802,273,280
3Apr 19, 2024 00:034,816120,925,45152,973,18302,260,992
4Apr 19, 2024 00:037,898112,143,95385,882,000998,0002,289,664
5Apr 19, 2024 00:037,900111,047,52384,900,0001,997,0002,265,088
6Apr 19, 2024 00:037,900114,931,98384,902,0001,997,0002,273,280
7Apr 19, 2024 00:037,903108,475,43384,935,0001,998,0002,289,664
8Apr 19, 2024 00:037,911109,240,30985,023,0002,000,0002,273,280
9Apr 19, 2024 00:037,912114,025,81385,032,0002,000,0002,527,232
10Apr 19, 2024 00:037,914110,406,08186,057,0001,000,0002,371,584
11Apr 19, 2024 00:037,915112,213,63285,069,0002,001,0002,289,664
12Apr 19, 2024 00:037,920110,934,94285,120,0002,002,0002,265,088