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 listMar 19, 2025 23:16Aniruddha DebAniruddha DebScore: 33,426Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Mar 19, 2025 23:0233,335390,722,186365,689,000999,0002,535,424
2Mar 19, 2025 23:0233,360391,041,220365,961,000999,0002,387,968
3Mar 19, 2025 23:0233,378388,630,022365,156,0002,000,0002,387,968
4Mar 19, 2025 23:0233,390389,720,339367,287,00002,535,424
5Mar 19, 2025 23:0233,393393,606,639366,325,0001,000,0002,535,424
6Mar 19, 2025 23:0233,414390,212,660366,555,000998,0002,387,968
7Mar 19, 2025 23:0233,426394,184,741365,690,0001,998,0002,273,280
8Mar 19, 2025 23:0233,427394,020,911366,697,000999,0002,535,424
9Mar 19, 2025 23:0233,462388,760,889366,084,0002,000,0002,535,424
10Mar 19, 2025 23:1633,642391,924,877370,064,00002,535,424
11Mar 19, 2025 23:1633,692402,164,344368,610,0001,997,0002,535,424
12Mar 19, 2025 23:1633,694397,847,969369,636,000999,0002,383,872