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 12, 2021 22:51Yuriy LyfenkoYuriy LyfenkoScore: 8,256Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 12, 2021 22:518,236122,212,46289,595,0001,006,0002,334,720
2May 12, 2021 22:518,238122,250,32889,614,0001,006,0002,330,624
3May 12, 2021 22:518,242117,526,40589,651,0001,007,0002,527,232
4May 12, 2021 22:518,242116,835,25390,660,00002,531,328
5May 12, 2021 22:518,256117,789,65986,825,0003,991,0002,330,624
6May 12, 2021 22:518,260120,029,88787,860,0002,995,0002,531,328
7May 12, 2021 22:518,260116,324,71290,855,00002,531,328
8May 12, 2021 22:518,260121,084,97689,860,000998,0002,330,624
9May 12, 2021 22:518,268115,357,68389,945,000999,0002,334,720