By memoization aproach, though it is not working