Abnormal jump step - to prove safety offer

A frog can jump on a Class 1 level, you can also hop on level 2 ...... n It can also jump on stage. The frog jumped seeking a total of n grade level how many jumps.

N is equal to the step jump level before jumping 1,2,3 ... n-1 and step 1 plus (n-th step jump directly)

public  class Solution {
     public  int JumpFloorII ( int target) {
         IF (target ==. 1 ) {
             return . 1 ; 
        } 
        int First =. 1 ;
         int SUM =. 1 ; // n-th step jump directly to this time
         for ( int I = 0; I <-target. 1; I ++ ) { 
            SUM + = First; 
            First = SUM; 
        } 
        return SUM; 
    } 
}

 

Guess you like

Origin www.cnblogs.com/nlw-blog/p/12412061.html