Hard
Given an n x n integer grid, a falling path with non-zero shifts chooses exactly one element from each row such that no two chosen elements in adjacent rows are in the same column. Return the minimum sum of such a falling path.
Input: grid = [[1,2,3],[4,5,6],[7,8,9]] Output: 13
Input: grid = [[7]] Output: 7