dynamic_programming on Jens Neuhalfen
https://neuhalfen.name/tags/dynamic_programming/
Recent content in dynamic_programming on Jens NeuhalfenHugo -- gohugo.ioenTue, 07 Jan 2020 00:00:00 +0100LeetCode #746 : Min cost climbing stairs
https://neuhalfen.name/blog/2020-01-leetcode-746-min_cost_climbing_stairs/
Tue, 07 Jan 2020 00:00:00 +0100https://neuhalfen.name/blog/2020-01-leetcode-746-min_cost_climbing_stairs/Description On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).
Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor, and you can either start from the step with index 0, or the step with index 1.
Example 1:
Input: cost = [10, 15, 20] Output: 15 Explanation: Cheapest is start on cost[1], pay that cost and go to the top.LeetCode #931. Minimum Falling Path Sum
https://neuhalfen.name/blog/2020-01-931-minimum-falling-path-sum/
Tue, 07 Jan 2020 00:00:00 +0100https://neuhalfen.name/blog/2020-01-931-minimum-falling-path-sum/Description Given a square array of integers A, we want the minimum sum of a falling path through A.
A falling path starts at any element in the first row, and chooses one element from each row. The next row's choice must be in a column that is different from the previous row's column by at most one.
Example 1:
Input: [[1,2,3],[4,5,6],[7,8,9]] Output: 12 Explanation: The possible falling paths are: