Question: 
Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.


Model's Code:
def find_length(binary_string, n):
    max_diff = 0
    count_0 = 0
    count_1 = 0
    diff_map = {0: -1}
    
    for i in range(n):
        if binary_string[i] == '0':
            count_0 += 1
        else:
            count_1 += 1
        
        current_diff = count_0 - count_1
        
        if current_diff in diff_map:
            max_diff = max(max_diff, i - diff_map[current_diff])
        else:
            diff_map[current_diff] = i
    
    return max_diff



Sample Correct Code:
def find_length(string, n): 
	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


Asserts:
assert find_length("11000010001", 11) == 6
assert find_length("10111", 5) == 1
assert find_length("11011101100101", 14) == 2 


Tests:
Test 1 of 3: FAIL: AssertionError()

Test 125 of 974: 92/125 (73.6%): failed