Design an API such that it can give unique Integers on every call. These itegers must be the smallest one possible. Users can also submit these integers back to the api such that these can now be allocated to other users.
Ex:
Input:
Request
Request
Request
Request
Delete 3
Delete 4
Request
Request
Request
Output:
1
2
3
4
Delete Successful
Delete Successful
3
4
5
Requests and deletes can be in billion , suggest most optimal approach.
Follow up:
What if the deletes are in some hundreds only?