How are all you coders doing?
Today we have an easy one for you. It’s a pretty interesting scenario, dealing with e-commerce orders. Can you solve it? Share your answer in a any programming language or pseudo-code on github gist and link it in the comments below.
You run an e-commerce website and want to record the last
orderids in a log. Implement a data structure to accomplish this, with the following API:
- record(order_id): adds the order_id to the log
- get_last(i): gets the ith last element from the log. i is guaranteed to be smaller than or equal to N.
You should be as efficient with time and space as possible.