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 listApr 19, 2024 01:06Joad NacerJoad NacerScore: 4,919Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 19, 2024 01:064,873123,471,47853,598,61502,269,184
2Apr 19, 2024 01:064,879121,526,36653,672,89302,265,088
3Apr 19, 2024 01:064,885132,798,98453,738,51202,400,256
4Apr 19, 2024 01:064,89678,417,96451,857,0001,994,0002,519,040
5Apr 19, 2024 01:064,89679,584,22551,865,0001,994,0002,265,088
6Apr 19, 2024 01:064,90876,037,14551,984,0001,999,0002,387,968
7Apr 19, 2024 01:064,91979,496,64852,102,0002,003,0002,527,232
8Apr 19, 2024 01:064,92081,512,23752,115,0002,004,0002,289,664
9Apr 19, 2024 01:064,92176,947,43953,128,0001,002,0002,289,664
10Apr 19, 2024 01:064,92377,774,67853,149,0001,002,0002,289,664
11Apr 19, 2024 01:064,92576,661,24552,173,0002,006,0002,289,664
12Apr 19, 2024 01:064,93886,150,55552,305,0002,011,0002,289,664