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 21:58Joad NacerJoad NacerScore: 10,965Success
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 21:5810,949193,029,979120,440,21502,269,184
2Apr 18, 2024 21:5810,955143,320,064119,501,0001,004,0002,273,280
3Apr 18, 2024 21:5810,958144,097,167119,532,0001,004,0002,523,136
4Apr 18, 2024 21:5810,961187,806,632120,568,05102,281,472
5Apr 18, 2024 21:5810,963190,416,342120,597,09102,273,280
6Apr 18, 2024 21:5810,964152,524,272119,603,0001,005,0002,289,664
7Apr 18, 2024 21:5810,965146,471,689119,611,0001,005,0002,289,664
8Apr 18, 2024 21:5810,981148,232,936119,797,000998,0002,289,664
9Apr 18, 2024 21:5810,984145,357,933118,831,0001,997,0002,289,664
10Apr 18, 2024 21:5810,997143,591,426119,964,000999,0002,289,664
11Apr 18, 2024 21:5811,008145,006,020119,086,0002,001,0002,269,184
12Apr 18, 2024 21:5811,011144,637,783119,124,0002,002,0002,289,664