Just added memoize to my growing catalog of interview questions.
Summary of the Challenge
There’s a lot of jargon in the question, but that’s not the point of this challenge. Make sure they understand the question. You might gauge how willing they are to ask questions, but only gently. Don’t put them on the defensive just by the wording of the question.
Part 1: You have a number of expensive pure functions. During the course of any given hour these functions are each called with a small number of inputs. Hour over hour the inputs vary dramatically. Describe how you could improve the performance of the system.
Candidate behaviors to look for: Caches the results and bypasses the expensive function calls when the answer is cached. Memoization. (See formal write up for details.)
Part 2: Write a higher order function (a function that takes a function and returns a function) that accepts a function of arity 1 and returns an identical, memoized function. (See formal write up for candidate template and example solution.)
Good At Differentiating Candidates
You will find that some candidates will solve the problem handily, refactor, then easily run through the examples. Other candidates might have to be coached more through the implementation, but should at least be able to step through the execution of the examples.