
    Given a student's semester attendance record as a sequence where '1' represents presence and '0' represents absence, find the time period (continuous sequence of days) with the largest disparity between absences and attendances to identify potential dropout risk patterns. The time period can be of any length within the semester, and the disparity is calculated as the absolute difference between the number of absences and presences within that period.
    

    
def find_length(string):
    """
    Given a student's semester attendance record as a sequence where '1' represents presence and '0' represents absence, find the time period (continuous sequence of days) with the largest disparity between absences and attendances to identify potential dropout risk patterns. The time period can be of any length within the semester, and the disparity is calculated as the absolute difference between the number of absences and presences within that period.
    

    """
def find_length(string):
    """
    Given a student's semester attendance record as a sequence where '1' represents presence and '0' represents absence, find the time period (continuous sequence of days) with the largest disparity between absences and attendances to identify potential dropout risk patterns. The time period can be of any length within the semester, and the disparity is calculated as the absolute difference between the number of absences and presences within that period.
    

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