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 3, 2021 00:49Yuriy LyfenkoYuriy LyfenkoScore: 5,720Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2021 00:495,71291,760,50562,829,00002,269,184
2May 3, 2021 00:495,71291,112,63861,840,000997,0002,273,280
3May 3, 2021 00:495,71685,238,52059,884,0002,994,0002,527,232
4May 3, 2021 00:495,72091,654,05460,918,0001,997,0002,523,136
5May 3, 2021 00:495,72085,524,91960,921,0001,997,0002,273,280
6May 3, 2021 00:495,72393,757,63359,958,0002,997,0002,281,472
7May 3, 2021 00:495,72485,991,09060,964,0001,998,0002,265,088
8May 3, 2021 00:495,72694,312,66860,990,0001,999,0002,281,472
9May 3, 2021 00:495,73287,818,86861,051,0002,001,0002,281,472