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 23:54Joad NacerJoad NacerScore: 7,920Success
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 23:544,778117,911,83352,553,01202,260,992
2Apr 18, 2024 23:544,784116,982,27252,618,78502,277,376
3Apr 18, 2024 23:544,792123,407,94052,707,84202,260,992
4Apr 18, 2024 23:547,901112,859,72984,911,0001,997,0002,527,232
5Apr 18, 2024 23:547,913109,352,11385,042,0002,000,0002,289,664
6Apr 18, 2024 23:547,919109,107,02485,106,0002,002,0002,285,568
7Apr 18, 2024 23:547,920113,920,86485,114,0002,002,0002,289,664
8Apr 18, 2024 23:547,920113,795,36385,121,0002,002,0002,289,664
9Apr 18, 2024 23:547,923108,668,25185,155,0002,003,0002,289,664
10Apr 18, 2024 23:547,928111,441,51486,202,0001,002,0002,289,664
11Apr 18, 2024 23:547,940116,556,79585,331,0002,007,0002,289,664
12Apr 18, 2024 23:547,965118,371,06486,603,0001,007,0002,289,664