Remembering perial solution for dynamic programming aproach