Closed andrewkmin closed 6 years ago
As mentioned in the README, everything tagged as a "Note" are comments of mine where I felt there was a need for stating assumptions or providing reasons for the implemented solution. I've kept these to a minimum on purpose, since such kind of comments do attract debates and bikeshedding ;)
Re: #16, the problem statement asks you to use the most efficient data structure wrt the API. Performance of get_last(n) rules out any structure based on linked lists, and record(id) requires fast head removal and tail insertions. An indexable queue is therefore the most appropriate data structure in this case, and a circular buffer is an efficient queue implementation when there's a known maximum number of elements https://goo.gl/6i3gKQ.
Generic queues are available in python as part of the collections package; see Deque https://goo.gl/M7WRWc. I implemented my circular buffer on top of a python list, nothing fancy here.
Hey you're doing some great stuff here. Quick question about some of your solutions -- are you going to be including intuition-based explanations (in addition to straight code) and potential runtimes?
For example, with problem 16, is circular_buffer a python-specific function? I was considering using a heap structure -- not sure if that's what they were going for...