worked on memoized version

Made helper function and finished cases 1 and 2