C ++ Program to find the maximum distance from a 0 - cell to a 1 - cell
#include <bits/stdc++.h> NEW_LINE using namespace std ; int maxDistance ( vector < vector < int > > & grid ) { vector < pair < int , int > > one ; int M = grid . size ( ) ; int N = grid [ 0 ] . size ( ) ; int ans = -1 ; for ( int i = 0 ; i < M ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) { if ( grid [ i ] [ j ] == 1 ) one . emplace_back ( i , j ) ; } }