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 listJan 7, 2024 23:57Yurkov AlekseyYurkov AlekseyScore: 6,622Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 7, 2024 23:576,59195,739,73572,506,00002,289,664
2Jan 7, 2024 23:576,59599,995,38571,534,0001,007,0002,289,664
3Jan 7, 2024 23:576,59893,647,28671,568,0001,008,0002,289,664
4Jan 7, 2024 23:576,59998,713,90471,583,0001,008,0002,531,328
5Jan 7, 2024 23:576,60199,862,84172,607,00002,289,664
6Jan 7, 2024 23:576,60996,083,05870,708,0001,991,0002,289,664
7Jan 7, 2024 23:576,622103,059,20070,848,0001,995,0002,265,088
8Jan 7, 2024 23:576,623101,764,80770,855,0001,995,0002,289,664
9Jan 7, 2024 23:576,625100,545,93170,882,0001,996,0002,523,136
10Jan 7, 2024 23:577,308150,049,81880,382,91402,273,280
11Jan 7, 2024 23:577,313151,502,49580,444,42202,269,184
12Jan 7, 2024 23:577,320137,824,39680,524,95202,269,184