【文件属性】:
文件名称:leetcode走楼梯-LeetCodes:LeetCodes
文件大小:8KB
文件格式:ZIP
更新时间:2021-07-01 06:01:27
系统开源
leetcode走楼梯
#LeetCode
Programming
##Dynamic
Programming
Codes
###ways
of
solving
DP
1)确认原问题与子问题
2)确认状态
3)确认边界状态的值
4)确定状态转移方程
Demos
:
You
are
climbing
a
stair
case.
It
takes
n
steps
to
reach
to
the
top.
Each
time
you
can
either
climb
1
or
2
steps.
In
how
many
distinct
ways
can
you
climb
to
the
top?
Note:
Given
n
will
be
a
positive
integer.
思路:
原问题求n阶台阶的所有的走法数量,子问题分解成求1,2,3......n-1阶的走法
状态为:第i阶台阶所有走法数量
边界:
i=1,i=2时台阶的走法,num[1]=1,num[2]=2
状态转移方程:
第i阶时的值(走法)依赖于
i-1,i-2时的值,最终的方程式为:num[i]=num[i-1]+num
【文件预览】:
LeetCodes-master
----pom.xml(2KB)
----src()
--------test()
--------main()
----.gitignore(34B)
----README.md(3KB)