Implement cacheSolve()