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 15:52Yuriy LyfenkoYuriy LyfenkoScore: 5,488Success
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 15:525,45487,208,88958,993,000999,0002,510,848
2May 22, 2021 15:525,45889,352,27858,041,0002,001,0002,527,232
3May 22, 2021 15:525,46683,294,88959,126,0001,002,0002,265,088
4May 22, 2021 15:525,46884,250,17658,140,0002,004,0002,527,232
5May 22, 2021 15:525,47587,676,39258,215,0002,007,0002,527,232
6May 22, 2021 15:525,48282,438,45760,297,00002,392,064
7May 22, 2021 15:525,48890,336,70559,361,0001,006,0002,265,088
8May 22, 2021 15:525,49086,346,04559,383,0001,006,0002,265,088
9May 22, 2021 15:525,835126,510,87064,185,11802,240,512
10May 22, 2021 15:525,845115,753,98464,295,35102,236,416
11May 22, 2021 15:525,847121,545,64164,315,95002,240,512
12May 22, 2021 15:526,25994,931,69366,853,0001,995,0002,387,968