题解 | #跳台阶#
跳台阶
https://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4
/** * * @param number int整型 * @return int整型 */ int jumpFloor(int number ) { // write code here int a1 = 1; int a2 = 2; int a3 = 3; if(number < 4) { switch(number) { case 1: return 1; break; case 2: return 2; break; case 3: return 3; break; } } for(int i = 4; i <= number; i++) { a1 = a2 + a3; a2 = a3; a3 = a1; } return a3; }