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 listMay 2, 2021 16:10Andrey TsvetkovAndrey TsvetkovScore: 12,079Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 16:1012,025153,637,290107,222,00025,051,0002,482,176
2May 2, 2021 16:1012,041156,583,27693,320,00039,134,0002,334,720
3May 2, 2021 16:1012,054161,059,801110,492,00022,098,0002,334,720
4May 2, 2021 16:1012,057157,968,837107,507,00025,118,0002,334,720
5May 2, 2021 16:1012,079156,744,75192,909,00039,961,0002,334,720
6May 2, 2021 16:1012,081159,590,846105,912,00026,977,0002,334,720
7May 2, 2021 16:1012,114163,974,834101,195,00032,061,0002,334,720
8May 2, 2021 16:1012,118156,763,745103,233,00030,067,0002,383,872
9May 2, 2021 16:1012,333160,805,624106,524,00029,143,0002,334,720