/**
* A frog can jump up to 1 steps at a time, or jump up to level 2. Ask the frog to jump on an n-level step with a total number of hops.
*/
Public classSolution { Public intJumpfloor (inttarget) { if(target<=2){ returnTarget; } intStart=1; intEnd =2; End= This. SUM (start,end,3, Target); returnend; }
/**
* Analyzed data: 1 2 3 5 8
*start before a step jumping method
*end Current Step Jumping method
*total Total Steps
*/ Public intSumintStartintEnd,intIintTotal ) { if(i<=Total ) { inttmp=start; Start=end; End+=tmp; End= This. SUM (start,end,i+1, total); } returnend; }}
/** * A frog can jump up to 1 steps at a time, or jump up to level 2 ... It can also jump on n levels. Ask the frog to jump on an n-level step. Total number of Hops */ /*** Data analysis 1 2 4* *publicclass Solution { publicint jumpfloorii (int target) { Return 1<< (target-1);} }
Frog Jumping-Algorithm