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 listDec 14, 2024 14:33E SequeiraE SequeiraScore: 303,219Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 14, 2024 14:33299,3533,323,246,1023,290,887,0001,998,0002,277,376
2Dec 14, 2024 14:33299,3823,321,983,2533,291,200,0001,998,0002,277,376
3Dec 14, 2024 14:33302,3633,354,934,0393,325,996,00002,277,376
4Dec 14, 2024 14:33303,1673,358,361,0043,333,837,000999,0002,519,040
5Dec 14, 2024 14:33303,2193,363,922,2333,333,409,0001,999,0002,285,568
6Dec 14, 2024 14:33303,7293,374,343,7563,339,024,0001,998,0002,277,376
7Dec 14, 2024 14:33303,8533,368,227,7173,340,385,0001,999,0002,514,944
8Dec 14, 2024 14:33304,4493,381,215,9043,345,941,0002,998,0002,277,376
9Dec 14, 2024 14:33328,3773,640,510,7343,610,154,0001,998,0002,510,848