剑指offer(8)跳台阶
public class Solution {
public int JumpFloor(int target) {
int first = 1;
int second = 2;
int result = 0;
if(target <= 0){
return 0;
}else if(target == 1){
return 1;
}else if(target == 2){
return 2;
}else{
for(int i = 3;i <= target;i++){
result = first + second;
first = second;
second = result;
}
return result;
}
}
}