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 20:47Joad NacerJoad NacerError
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 20:4500000Error: Killed by timeoutstderr
2Apr 18, 2024 20:4713,773175,834,280150,503,0001,003,0002,273,280
3Apr 18, 2024 20:4713,779178,381,040151,573,00002,289,664
4Apr 18, 2024 20:4713,787178,709,370150,657,0001,004,0002,392,064
5Apr 18, 2024 20:4713,788175,411,898150,676,000997,0002,265,088
6Apr 18, 2024 20:4713,789178,107,900149,680,0001,995,0002,277,376
7Apr 18, 2024 20:4713,801179,401,105149,809,0001,997,0002,289,664
8Apr 18, 2024 20:4713,814183,250,398149,956,0001,999,0002,289,664
9Apr 18, 2024 20:4713,814176,419,177149,958,0001,999,0002,289,664
10Apr 18, 2024 20:4713,822179,027,267150,046,0002,000,0002,265,088
11Apr 18, 2024 20:4713,877214,587,177152,647,75602,252,800
12Apr 18, 2024 20:4713,891213,026,729152,798,95002,265,088
13Apr 18, 2024 20:4713,946214,208,806153,403,67902,273,280