using a memorization technique