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:58Joad NacerJoad NacerScore: 8,460Success
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:585,324128,870,30158,559,84302,269,184
2Apr 18, 2024 23:585,330127,395,76058,631,85002,277,376
3Apr 18, 2024 23:585,347129,181,99058,812,93802,260,992
4Apr 18, 2024 23:588,446123,607,18691,910,000999,0002,281,472
5Apr 18, 2024 23:588,456119,483,35592,021,0001,000,0002,281,472
6Apr 18, 2024 23:588,459117,197,72992,052,0001,000,0002,527,232
7Apr 18, 2024 23:588,460117,003,92891,058,0002,001,0002,289,664
8Apr 18, 2024 23:588,467115,629,35292,138,0001,001,0002,273,280
9Apr 18, 2024 23:588,469118,232,81291,156,0002,003,0002,273,280
10Apr 18, 2024 23:588,474119,307,15491,208,0002,004,0002,387,968
11Apr 18, 2024 23:588,486120,295,35292,347,0001,003,0002,289,664
12Apr 18, 2024 23:588,488116,595,57292,361,0001,003,0002,289,664