[劍指offer]跳臺階

思路: 跳一節有一種,跳兩節有兩種,跳三節有f(1)+f(2)種,跳N節有f(N-1)+f(N-2)種,就是一個斐波那契數列。 實現: public class Solution { public int JumpFloor(int target) { if(target<=2)return target; int n1=1; int n2=
相關文章
相關標籤/搜索