Implemented cacheSolve()