
    Given a student's performance record as a sequence where '1' represents mastery of a learning objective and '0' represents a need for improvement, find the learning segment (continuous period) with the largest disparity between mastered and unmastered objectives. The difference is calculated by subtracting the count of mastered objectives from unmastered ones in each possible learning segment, helping identify the most critical period for intervention.
    

    
def find_length(string):
    """
    Given a student's performance record as a sequence where '1' represents mastery of a learning objective and '0' represents a need for improvement, find the learning segment (continuous period) with the largest disparity between mastered and unmastered objectives. The difference is calculated by subtracting the count of mastered objectives from unmastered ones in each possible learning segment, helping identify the most critical period for intervention.
    

    """
def find_length(string):
    """
    Given a student's performance record as a sequence where '1' represents mastery of a learning objective and '0' represents a need for improvement, find the learning segment (continuous period) with the largest disparity between mastered and unmastered objectives. The difference is calculated by subtracting the count of mastered objectives from unmastered ones in each possible learning segment, helping identify the most critical period for intervention.
    

    """
    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