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 listJun 4, 2024 16:57Joad NacerJoad NacerScore: 7,199Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 4, 2024 16:574,720111,279,85451,916,62202,273,280
2Jun 4, 2024 16:574,720116,935,57051,919,54602,273,280
3Jun 4, 2024 16:574,729116,821,39652,017,48702,273,280
4Jun 4, 2024 16:577,189103,902,57978,081,0001,001,0002,514,944
5Jun 4, 2024 16:577,193103,305,17077,124,0002,003,0002,281,472
6Jun 4, 2024 16:577,195107,708,97578,144,0001,001,0002,285,568
7Jun 4, 2024 16:577,199104,704,97577,181,0002,004,0002,285,568
8Jun 4, 2024 16:577,199104,117,99678,184,0001,002,0002,281,472
9Jun 4, 2024 16:577,201107,207,91478,209,0001,002,0002,281,472
10Jun 4, 2024 16:577,201108,305,51077,211,0002,005,0002,285,568
11Jun 4, 2024 16:577,202100,166,56777,215,0002,005,0002,285,568
12Jun 4, 2024 16:577,205105,942,05577,244,0002,006,0002,285,568