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:50Yuriy LyfenkoYuriy LyfenkoScore: 5,714Success
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:505,71093,081,08361,812,000996,0002,281,472
2May 3, 2021 00:505,71286,109,54360,838,0001,994,0002,273,280
3May 3, 2021 00:505,71393,274,56961,851,000997,0002,273,280
4May 3, 2021 00:505,71488,729,09161,852,000997,0002,277,376
5May 3, 2021 00:505,71493,648,31261,860,000997,0002,523,136
6May 3, 2021 00:505,71584,905,47660,866,0001,995,0002,387,968
7May 3, 2021 00:505,72488,059,52358,963,0003,997,0002,277,376
8May 3, 2021 00:505,73287,007,44361,053,0002,001,0002,379,776
9May 3, 2021 00:505,73585,653,68662,083,0001,001,0002,281,472