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 listSep 4, 2024 09:55Joad NacerJoad NacerScore: 4,869Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 4, 2024 09:554,85374,331,92553,386,00002,273,280
2Sep 4, 2024 09:554,86274,023,04053,485,00002,273,280
3Sep 4, 2024 09:554,86474,475,33453,507,00002,273,280
4Sep 4, 2024 09:554,86882,355,01252,538,0001,010,0002,433,024
5Sep 4, 2024 09:554,86977,941,55253,557,00002,535,424
6Sep 4, 2024 09:554,87182,863,66653,576,00002,428,928
7Sep 4, 2024 09:554,87278,496,80952,579,0001,011,0002,535,424
8Sep 4, 2024 09:554,87684,274,79253,636,00002,535,424
9Sep 4, 2024 09:554,87980,014,17752,652,0001,012,0002,535,424