public static boolean search2DMatrix(int[][] matrix, int target) {
        
        int start = 0; 
        int end = matrix.length-1;
        int row=0;
        
    	while(start<=end)
    	{
    		int midrow = (start + end)/2;
    		if(target<matrix[midrow][0])
    		{
    			end = midrow-1;
    		}else if(target>=matrix[midrow][0] && (midrow==matrix.length-1 || target<matrix[midrow+1][0]))
    		{
    			row = midrow; 
    			break;
    		}else
    		{
    			start = midrow+1;
    		}
    	}
    	start = 0;
    	end = matrix[0].length-1;
    	while(start<=end)
    	{
    		int mid = (start + end)/2;
    		if(target<matrix[row][mid])
    		{
    			end = mid-1;
    		}else if(target==matrix[row][mid])
    		{
    			return true;
    		}else
    		{
    			start = mid+1;
    		}
    	}
    	
    	return false;
    	
    }