0064_minimum-path-sum

command
v0.0.0-...-60194e6 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Unlicense Imports: 0 Imported by: 0

README

0064_minimum-path-sum

最基础的dp!!!

题目要求只能向右或者向下走.

dp[i][j] 是从左上到达该点的答案, 则:

  • 第一列和第一行只有一种走法
  • 除第一列和第一行, dp[i][j] = min{ dp[i-1][j], dp[i][j-1] } + grid[i][j]

如果对空间要求严格, 且可以改变输入, 我们可以把dp数据直接覆盖到输入上.

更多

考虑允许向左或者向上走的情况:

  • 如果可以向左或者向上走, 格子都为正数的情况绝对不会是最优解
    • 如果格子可为0...?
    • 如果格子值可为负
      • 不限制步数的话, 可能会出现循环踩两个格子的情况
      • 每个格子只能走一遍...?

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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