Commit graph

3 commits

Author SHA1 Message Date
William Carroll
155dff562a Impl part 3/3 for Memo
Refactor the caching policy for the Memo by evicting the elements that have been
the least-recently-accessed.

Python's heapq module default to a min-heap. By storing our heap elements
as (UnixTime, a), we can guarantee that when we call heappop, we will get the
element with the lowest UnixTime value in heap (i.e. the oldest). When we call
heappush, we use (time.time(), key) and these values -- by having the largest
UnixTime, will propogate to the bottom of the min-heap.
2020-07-01 15:13:56 +01:00
William Carroll
a8b3a2d3c0 Support part 2/3 for the Memo problem
Bound the size of the memo by creating a BoundedQueue. Whenever we add elements
to the BoundedQueue, we remove the oldest elements. We use the BoundedQueue to
control the size of our dictionary that we're using to store our key-value pairs.
2020-07-01 14:59:49 +01:00
William Carroll
ec7c8516f7 Implement part 1/3 for "Memo"
After hearing from a Jane Street recruiter, I decided to dust off some of the
DS&As knowledge. I found this article online, which outlines an example problem
called "Memo":

https://blog.janestreet.com/what-a-jane-street-dev-interview-is-like/

Here's part 1 of the solution in Python.
2020-07-01 14:40:40 +01:00