from kata_075 import largest_histogram

def maximal_rectangle(matrix):
    if not matrix or not matrix[0]:
        return 0
    heights = [0] * len(matrix[0])
    best = 0
    for row in matrix:
        for c, value in enumerate(row):
            heights[c] = heights[c] + 1 if value == 1 else 0
        best = max(best, largest_histogram(heights))
    return best
