
    Given a customer's daily spending pattern where '1' represents above-average spending days and '0' represents normal spending days, find the time period that shows the maximum imbalance between conservative and excessive spending behavior. The imbalance is calculated as the absolute difference between the number of normal spending days and high-spending days within any continuous period of the customer's financial history.
    

    
def find_length(string):
    """
    Given a customer's daily spending pattern where '1' represents above-average spending days and '0' represents normal spending days, find the time period that shows the maximum imbalance between conservative and excessive spending behavior. The imbalance is calculated as the absolute difference between the number of normal spending days and high-spending days within any continuous period of the customer's financial history.
    

    """
def find_length(string):
    """
    Given a customer's daily spending pattern where '1' represents above-average spending days and '0' represents normal spending days, find the time period that shows the maximum imbalance between conservative and excessive spending behavior. The imbalance is calculated as the absolute difference between the number of normal spending days and high-spending days within any continuous period of the customer's financial history.
    

    """
    n = len(string)
    current_sum = 0
    max_sum = 0
    for i in range(n):
        current_sum += 1 if string[i] == '0' else -1
        if current_sum < 0:
            current_sum = 0
        max_sum = max(current_sum, max_sum)
    return max_sum if max_sum else 0