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 listJun 4, 2021 11:57Yurkov AlekseyYurkov AlekseyError
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 4, 2021 11:5400000Error: died or killed
2Jun 4, 2021 11:576,65896,211,91572,234,0001,003,0002,277,376
3Jun 4, 2021 11:576,666101,054,91373,321,00002,273,280
4Jun 4, 2021 11:576,67797,994,62472,443,0001,006,0002,277,376
5Jun 4, 2021 11:576,67899,683,51373,454,00002,277,376
6Jun 4, 2021 11:576,68294,898,01572,491,0001,006,0002,375,680
7Jun 4, 2021 11:576,68296,307,14571,484,0002,013,0002,277,376
8Jun 4, 2021 11:576,68396,057,45572,503,0001,006,0002,277,376
9Jun 4, 2021 11:576,683104,620,58172,510,0001,007,0002,277,376
10Jun 4, 2021 11:576,68696,742,81772,540,0001,007,0002,523,136
11Jun 4, 2021 11:577,464144,822,09482,098,96702,265,088
12Jun 4, 2021 11:577,497134,595,64982,470,92602,269,184
13Jun 4, 2021 11:577,509144,953,41482,599,28102,265,088