Company: infosys_11oct
Difficulty: medium
Minimum Cost Grid Path Problem Description We have a grid with H rows and W columns, where each square is either white or black . For each square at position (i, j) — the i-th row from the top and j-th column from the left — the color is represented by A[i][j] : If A[i][j] = 0 , the square is white. If A[i][j] = 1 , the square is black. You can perform the operations described below any number of times, in any order: Row Flip: Choose a row i ( 1 ), pay R[i] yen, and invert the color of every square in that row — white squares turn black, and black squares turn white. Column Flip: Choose a column j ( 1 ), pay C[j] yen, and invert the color of every square in that column. You need to ensure there's a valid path from the top-left square (1, 1) to the bottom-right square (H, W) . This path should consist only of squares that have the same color , and you can only move down or right at each step. Your task is to find the minimum total cost to achieve this. Note: It's guara