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 22:16Yuriy LyfenkoYuriy LyfenkoScore: 8,695Success
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 22:168,671118,033,07094,379,0001,004,0002,334,720
2May 22, 2021 22:168,684121,286,17494,516,0001,005,0002,400,256
3May 22, 2021 22:168,690118,221,47894,581,0001,006,0002,400,256
4May 22, 2021 22:168,691159,733,26195,604,35302,191,360
5May 22, 2021 22:168,693127,023,20593,607,0002,013,0002,535,424
6May 22, 2021 22:168,695157,611,99495,647,42902,187,264
7May 22, 2021 22:168,695120,265,20994,636,0001,006,0002,334,720
8May 22, 2021 22:168,695122,089,09593,632,0002,013,0002,334,720
9May 22, 2021 22:168,695125,738,15293,635,0002,013,0002,326,528
10May 22, 2021 22:168,715122,895,31393,870,0001,997,0002,334,720
11May 22, 2021 22:168,722166,547,61595,944,66902,191,360
12May 22, 2021 22:168,803121,462,61693,836,0002,994,0002,531,328