Function to flip the minimum number of cells such that there doesn 't exists any such path from (0, 0) to (N - 1, M - 1) cell consisting of 0s
function solve ( matrix ) { let N = matrix . length ; let M = matrix [ 0 ] . length ;