This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Given a m x n grid filled with non-negative numbers, find a path from top left | |
# to bottom right which minimizes the sum of all numbers along its path. | |
def minimum_path_sum(grid) | |
m, n = detect_grid_size(grid) | |
validate_grid!(grid, n) | |
# Prepare table that contains path cost | |
path_cost = Array.new(m) { Array.new(n) { 0 } } |