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 18, 2024 23:59Joad NacerJoad NacerScore: 7,922Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 18, 2024 23:594,821116,166,80153,035,46502,265,088
2Apr 18, 2024 23:594,839119,180,19253,229,41202,273,280
3Apr 18, 2024 23:594,841115,712,67953,254,30202,260,992
4Apr 18, 2024 23:597,920116,097,88785,117,0002,002,0002,289,664
5Apr 18, 2024 23:597,920107,673,95085,118,0002,002,0002,531,328
6Apr 18, 2024 23:597,920110,221,06587,122,00002,281,472
7Apr 18, 2024 23:597,922110,455,06685,144,0002,003,0002,527,232
8Apr 18, 2024 23:597,933109,406,52585,253,0002,005,0002,289,664
9Apr 18, 2024 23:597,938115,770,34986,326,000992,0002,273,280
10Apr 18, 2024 23:597,949109,702,98887,444,00002,269,184
11Apr 18, 2024 23:597,956108,658,99087,516,00002,289,664
12Apr 18, 2024 23:597,964113,955,53486,593,0001,006,0002,289,664