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 3, 2021 00:44Yuriy LyfenkoYuriy LyfenkoScore: 5,732Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2021 00:445,71387,512,81261,844,000997,0002,527,232
2May 3, 2021 00:445,72089,701,56059,923,0002,996,0002,269,184
3May 3, 2021 00:445,72085,229,07959,929,0002,996,0002,265,088
4May 3, 2021 00:445,72786,271,38462,002,0001,000,0002,281,472
5May 3, 2021 00:445,73289,226,00761,047,0002,001,0002,277,376
6May 3, 2021 00:445,73585,032,23961,087,0002,002,0002,281,472
7May 3, 2021 00:445,73885,046,02261,110,0002,003,0002,269,184
8May 3, 2021 00:445,74085,677,76361,134,0002,004,0002,281,472
9May 3, 2021 00:445,74790,244,12060,202,0003,010,0002,273,280