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 22, 2021 21:56Yuriy LyfenkoYuriy LyfenkoScore: 3,912Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2021 21:563,89767,148,27841,868,000996,0002,392,064
2May 22, 2021 21:563,90168,906,88641,909,000997,0002,527,232
3May 22, 2021 21:563,90271,472,51641,925,000998,0002,265,088
4May 22, 2021 21:563,90373,788,58741,935,000998,0002,527,232
5May 22, 2021 21:563,90569,893,35741,956,000998,0002,265,088
6May 22, 2021 21:563,90573,652,88840,959,0001,998,0002,392,064
7May 22, 2021 21:563,91267,229,38042,032,0001,000,0002,265,088
8May 22, 2021 21:563,91468,623,09542,058,0001,001,0002,392,064
9May 22, 2021 21:563,91576,680,57942,062,0001,001,0002,527,232
10May 22, 2021 21:564,023110,895,61044,249,66702,236,416
11May 22, 2021 21:564,038107,301,01044,421,58502,236,416
12May 22, 2021 21:564,041104,868,13744,454,03502,236,416