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 18, 2024 21:56Joad NacerJoad NacerScore: 10,985Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 18, 2024 21:5610,958146,565,768119,533,0001,004,0002,289,664
2Apr 18, 2024 21:5610,966145,549,282120,621,00002,289,664
3Apr 18, 2024 21:5610,978194,015,224120,757,14302,265,088
4Apr 18, 2024 21:5610,982147,307,070120,806,00002,269,184
5Apr 18, 2024 21:5610,985151,513,525119,833,000998,0002,289,664
6Apr 18, 2024 21:5610,985153,149,941118,834,0001,997,0002,289,664
7Apr 18, 2024 21:5610,985150,796,382119,835,000998,0002,289,664
8Apr 18, 2024 21:5610,985150,137,453118,837,0001,997,0002,531,328
9Apr 18, 2024 21:5610,991149,209,942118,900,0001,998,0002,523,136
10Apr 18, 2024 21:5610,995185,497,861120,944,78802,265,088
11Apr 18, 2024 21:5610,998185,486,212120,973,93002,269,184
12Apr 18, 2024 21:5611,011149,057,488119,119,0002,002,0002,265,088