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 listJul 29, 2024 09:09Andrey LikhachevAndrey LikhachevScore: 7,291Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 29, 2024 09:097,273151,659,87280,007,15702,351,104
2Jul 29, 2024 09:097,274107,704,53478,009,0002,000,0002,363,392
3Jul 29, 2024 09:097,274110,021,94179,018,0001,000,0002,289,664
4Jul 29, 2024 09:097,278107,269,64679,061,0001,000,0002,375,680
5Jul 29, 2024 09:097,288104,750,24478,168,0002,004,0002,367,488
6Jul 29, 2024 09:097,289107,035,09778,180,0002,004,0002,355,200
7Jul 29, 2024 09:097,291101,344,08678,198,0002,005,0002,363,392
8Jul 29, 2024 09:097,310140,919,14380,406,01402,207,744
9Jul 29, 2024 09:097,312103,824,50280,427,00002,289,664
10Jul 29, 2024 09:097,313101,530,81679,437,0001,005,0002,281,472
11Jul 29, 2024 09:097,318103,478,97379,489,0001,006,0002,363,392
12Jul 29, 2024 09:097,334145,682,26180,670,32902,199,552