public static boolean searchMatrix(int[][] matrix, int target) {
		int row = 0;
		int i = 0;

		for (i = 0; i < matrix.length; i++) {
			if (target < matrix[i][0]) {
				row = i - 1;
				break;
			}

		}
		if (i == matrix.length) {
			row = matrix.length - 1;
		}
		if (row < 0)
			row = 0;
		for (int j = 0; j < matrix[0].length; j++) {
			// you can do better if you apply binary search here.
			if (target == matrix[row][j])
				return true;
		}
		return false;

	}