标签:bin air com val div tar until rip turn
package LeetCode_70 /** * 70. Climbing Stairs * https://leetcode.com/problems/climbing-stairs/description/ * */ class Solution { fun climbStairs(n: Int): Int { if (n <= 2) { return n } //method 1: TLE //return climbStairs(n-1)+climbStairs(n-2) //dp val dp = IntArray(n) dp[0] = 1 dp[1] = 2 for (i in 2 until n) { dp[i] = dp[i - 2] + dp[i - 1] } return dp[dp.size - 1] } }
标签:bin air com val div tar until rip turn
原文地址:https://www.cnblogs.com/johnnyzhao/p/12635595.html