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:16Joad NacerJoad NacerScore: 7,623Success
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:165,053130,025,31055,583,26002,269,184
2Apr 18, 2024 23:165,057122,772,17055,629,57402,269,184
3Apr 18, 2024 23:165,077113,704,67555,843,45702,260,992
4Apr 18, 2024 23:167,618110,888,03783,797,00002,289,664
5Apr 18, 2024 23:167,620110,104,45282,828,000997,0002,383,872
6Apr 18, 2024 23:167,621112,640,96381,834,0001,995,0002,289,664
7Apr 18, 2024 23:167,623110,793,89181,852,0001,996,0002,289,664
8Apr 18, 2024 23:167,630112,775,83481,935,0001,998,0002,265,088
9Apr 18, 2024 23:167,631107,661,43381,938,0001,998,0002,289,664
10Apr 18, 2024 23:167,631110,161,94281,944,0001,998,0002,289,664
11Apr 18, 2024 23:167,633108,103,89881,965,0001,999,0002,289,664
12Apr 18, 2024 23:167,639111,778,58183,031,0001,000,0002,289,664