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 19, 2024 11:57Joad NacerJoad NacerScore: 6,230Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 19, 2024 11:576,21089,537,29267,310,0001,004,0002,383,872
2Apr 19, 2024 11:576,21989,827,03868,412,00002,273,280
3Apr 19, 2024 11:576,22090,011,64468,421,00002,269,184
4Apr 19, 2024 11:576,22194,800,08267,422,0001,006,0002,289,664
5Apr 19, 2024 11:576,22190,629,88567,427,0001,006,0002,289,664
6Apr 19, 2024 11:576,22591,421,13567,467,0001,006,0002,273,280
7Apr 19, 2024 11:576,23090,542,29167,524,0001,007,0002,269,184
8Apr 19, 2024 11:576,23597,803,74967,575,0001,008,0002,289,664
9Apr 19, 2024 11:576,25898,112,46466,848,0001,995,0002,523,136
10Apr 19, 2024 11:576,334125,875,06269,678,00202,273,280
11Apr 19, 2024 11:576,336132,804,86669,690,53802,281,472
12Apr 19, 2024 11:576,350132,680,93669,853,64502,273,280