Create Statistics endpoint
Closed this issue · 0 comments
GET /statistics
This is the main endpoint of this task, this endpoint have to execute in constant time and
memory (O(1))
. It returns the statistic based on the transactions which happened in the last 60
seconds.
Returns:
{
"sum": 1000,
"avg": 100,
"max": 200,
"min": 50,
"count": 10
}
Where:
● sum is a double specifying the total sum of transaction value in the last 60 seconds
● avg is a double specifying the average amount of transaction value in the last 60
seconds
● max is a double specifying single highest transaction value in the last 60 seconds
● min is a double specifying single lowest transaction value in the last 60 seconds
● count is a long specifying the total number of transactions happened in the last 60
seconds
Requirements
For the rest api, the biggest and maybe hardest requirement is to make the GET /statistics
execute in constant time and space. The best solution would be O(1)
. It is very recommended to
tackle the O(1)
requirement as the last thing to do as it is not the only thing which will be rated in
the code challenge.