classSolution{public:intclimbStairs(intn){// Note: The Solution object is instantiated only once and is reused by each test case.
inta1=1;inta2=2;if(n==1){returna1;}if(n==2){returna2;}intindex=3;intbefore=a2;intnow=a1+a2;while(true){if(index==n){returnnow;}inttmp=before;before=now;now=tmp+before;index++;}}};