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 17:23Yuriy LyfenkoYuriy LyfenkoScore: 6,278Success
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 17:236,26095,582,36566,860,0001,995,0002,334,720
2May 22, 2021 17:236,26097,103,41365,870,0002,994,0002,334,720
3May 22, 2021 17:236,26495,935,10965,907,0002,995,0002,314,240
4May 22, 2021 17:236,266103,202,63266,928,0001,997,0002,334,720
5May 22, 2021 17:236,27193,415,54965,981,0002,999,0002,334,720
6May 22, 2021 17:236,276129,506,38469,037,92302,183,168
7May 22, 2021 17:236,27893,520,34066,051,0003,002,0002,334,720
8May 22, 2021 17:236,27895,779,87966,051,0003,002,0002,527,232
9May 22, 2021 17:236,28897,134,70567,166,0002,004,0002,330,624
10May 22, 2021 17:236,28892,814,57366,166,0003,007,0002,334,720
11May 22, 2021 17:236,292131,228,10669,211,99202,183,168
12May 22, 2021 17:236,295138,659,59569,249,75102,191,360