刷题
LeetCode
HSalome
这个作者很懒,什么都没留下…
展开
-
198.打家劫舍
LeetCode 198 打家劫舍 fun(n) = max(arr[n] + fun(n - 2), fun(n - 1)) int max(int a, int b) { if (a > b) b = a; return b; } int rob(int* nums, int numsSize){ if (numsSize <= 0) return 0; if (numsSize == 1) return nums[numsSize - 1];原创 2021-05-21 17:52:38 · 136 阅读 · 0 评论 -
70.爬楼梯
LeetCode 70 爬楼梯 int climbStairs(int n){ if (n == 0) return 0; if (n == 1) return 1; if (n == 2) return 2; if (n == 3) return 3; int arr[n + 1]; arr[1] = 1, arr[2] = 2, arr[3] = 3; for (int i = 4; i < n + 1; i++) { ar原创 2021-05-21 17:15:19 · 197 阅读 · 0 评论