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 23, 2024 17:46Joad NacerJoad NacerScore: 7,544Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 23, 2024 17:465,180124,659,32056,985,18502,277,376
2Apr 23, 2024 17:465,185122,620,26657,038,75102,273,280
3Apr 23, 2024 17:465,224122,544,01757,464,12102,265,088
4Apr 23, 2024 17:467,530110,364,45680,831,0001,995,0002,277,376
5Apr 23, 2024 17:467,533114,154,65481,864,000998,0002,289,664
6Apr 23, 2024 17:467,534109,295,25181,880,000998,0002,523,136
7Apr 23, 2024 17:467,544105,124,74480,986,0001,999,0002,289,664
8Apr 23, 2024 17:467,582105,530,17382,397,0001,004,0002,289,664
9Apr 23, 2024 17:467,587107,505,75182,457,0001,005,0002,289,664
10Apr 23, 2024 17:467,589108,815,05582,477,0001,005,0002,289,664
11Apr 23, 2024 17:467,623107,366,63181,860,0001,996,0002,289,664
12Apr 23, 2024 17:467,625111,996,30781,874,0001,996,0002,289,664