ldp

package
v0.0.0-...-d229d73 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

https://leetcode.com/problems/climbing-stairs/#/description

ou 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层,那么如何爬到第n层呢,因为每次只能爬1或2步,那么爬到第n层的方法要么是从第n-1层一步上来的,要不就是从n-2层2步上来的,所以递推公式非常容易的就得出了: dp[n] = dp[n-1] + dp[n-2] (上第n层只有两种解法) 如果梯子有1层或者2层,dp[1] = 1, dp[2] = 2,如果梯子有0层,自然dp[0] = 0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NumArray

type NumArray struct {
	// contains filtered or unexported fields
}

func Constructor

func Constructor(nums []int) NumArray

func (*NumArray) SumRange

func (this *NumArray) SumRange(i int, j int) int

type NumMatrix

type NumMatrix struct {
	// contains filtered or unexported fields
}

func NumMatrixConstructor

func NumMatrixConstructor(matrix [][]int) NumMatrix

func (*NumMatrix) SumRegion

func (this *NumMatrix) SumRegion(row1 int, col1 int, row2 int, col2 int) int

type TreeNode

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

func (*TreeNode) String

func (t *TreeNode) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL