7 matrices/6 search in sorted matrix/main.cpp
/*
Given a matrix which is row wise and column wise matrix 
find index of given element(if not present -1)

ex: for row wise and column wise sorted matrix{
    {10,20,30,40},
    {15,25,35,45},
    {27,39,37,48},
    {32,33,39,50}
}
*/
Given a matrix which is row wise and column wise matrix
find index of given element(if not present -1)


Given a matrix which is row wise and column wise matrix find index of given element ( if not present - 1 )
pair<int,int> naive_search(vector<vector<int>> &mat, int x){    
    for(int i=0;i<mat.size();i++){
        for(int j=0;j<mat[i].size();j++){
            if(mat[i][j]==x)
                return make_pair(i,j);
        }
    }
    return make_pair(-1,-1);
}
pair < int , int > naive_search ( vector < vector < int > > & mat , int x ) { for ( int i = 0 ; i < mat . size ( ) ; i ++ ) { for ( int j = 0 ; j < mat [ i ] . size ( ) ; j ++ ) { if ( mat [ i ] [ j ] == x ) return make_pair ( i , j ) ; } } return make_pair ( -1 , -1 ) ; }
Given a matrix which is row wise and column wise matrix
find index of given element(if not present -1)
Given a matrix which is row wise and column wise matrix find index of given element ( if not present - 1 )
//O(n*n) time and O(1) space