You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Solution: DP
ways[n]=ways[n-1]+ways[n-2];
No matter what n is, it must be reached from n-1 or n-2 , then use array to record unique ways from 0 to end
No comments:
Post a Comment