|
|
back to boardSolving using the height of last step Posted by Gokul 21 Apr 2018 01:10 Hi All, Just want to share my experience solving this problem. I did it like this let the i be the number of bricks available and j be the height of the last step. S[i][j] = sum(S[i-j][:j]) + (1 if (i-j) < j else 0) So basically all i am doing is the number of stairs with i bricks and height j is also the same number of stairs with i-j bricks and max height of j - 1(hence the array stops at index j) and one more if i - j bricks are less than height j. There might be more slick solution avaiable, but this worked for me :) Edited by author 21.04.2018 01:11 |
|
|