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 listMay 5, 2021 10:32Yurkov AlekseyYurkov AlekseyScore: 6,717Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 5, 2021 10:326,71399,665,66672,845,000997,0002,527,232
2May 5, 2021 10:326,713101,353,01472,846,000997,0002,527,232
3May 5, 2021 10:326,71398,726,54672,848,000997,0002,277,376
4May 5, 2021 10:326,71697,574,00272,873,000998,0002,519,040
5May 5, 2021 10:326,717105,969,66971,891,0001,996,0002,277,376
6May 5, 2021 10:326,71899,878,79871,898,0001,997,0002,277,376
7May 5, 2021 10:326,720105,277,74571,926,0001,997,0002,277,376
8May 5, 2021 10:326,73296,790,41872,053,0002,001,0002,273,280
9May 5, 2021 10:326,73497,131,04572,069,0002,001,0002,269,184