public class Solution {
public int JumpFloor(int target) {
if (target == 1)
return 1;
if (target == 2)
return 2;
int[] array = new int [target + 1];
array[1] = 1;
array[2] = 2;
for (int i = 3; i <= target; i++)
array[i] = array[i-1] + array[i-2];
return array[target];
}
}
跳台阶
最新推荐文章于 2024-03-30 21:52:58 发布