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 2, 2021 07:01Yuriy LyfenkoYuriy LyfenkoScore: 12,023Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 07:0111,998160,500,642129,978,0001,999,0002,396,160
2May 2, 2021 07:0112,013160,523,085131,144,0001,001,0002,392,064
3May 2, 2021 07:0112,020156,702,040130,216,0002,003,0002,396,160
4May 2, 2021 07:0112,022156,283,564129,236,0003,005,0002,396,160
5May 2, 2021 07:0112,023156,462,249131,255,0001,001,0002,260,992
6May 2, 2021 07:0112,024157,784,536132,268,00002,260,992
7May 2, 2021 07:0112,042158,209,808132,462,00002,265,088
8May 2, 2021 07:0112,051160,832,194131,560,0001,004,0002,379,776
9May 2, 2021 07:0112,075162,718,462130,829,0001,997,0002,387,968