问题描述:
Write a function to find out the minimum no of swaps required for bracket balancing in the given string.

测试用例:
['assert swap_count("[]][][") == 2', 'assert swap_count("[[][]]") == 0', 'assert swap_count("[[][]]][") == 1']

生成的代码:
def swap_count(s):
    left = 0
    right = 0
    swaps = 0

    for char in s:
        if char == '[':
            left += 1
            if right > 0:
                swaps += right
                right -= 1
        else:
            right += 1
    
    return swaps

# Test cases
assert swap_count("[]][][") == 2
assert swap_count("[[][]]") == 0
assert swap_count("[[][]]][") == 1