题目
解法
\[fn=
\left\{
\begin{array}{**lr**}
min(f_{n-1}, f_{n-2})\ +\ n, & n\geq 3 \\
n, & n=0|n=1 & \\
\end{array}
\right.
\]
class Solution {
/**
* @param Integer[] $cost
* @return Integer
*/
function minCostClimbingStairs($cost) {
$ret = [$cost[0], $cost[1]];
for ($i = 2; $i <= count($cost); $i++) {
$ret[$i] = min($ret[$i-1], $ret[$i-2]) + $cost[$i];
}
return $ret[count($cost)];
}