<jupyter_start><jupyter_text><jupyter_code>def solution(S):
    
    a = ["{", "(", "["]
    b = ["}",")","]"]
    a_dict = {v:i for i,v in zip(a,b)}
    
    stack = []

    for i in S:
        if i in a:
            stack.append(i)
        elif i in b and stack:
            if stack and a_dict.get(i) == stack[-1]:
                stack.pop()
            else:
                return 0
    return int(not stack)
# 다른사람 풀이 깔끔.
def solution(S):

    matches, stack = dict(['()', '[]', '{}']), []
    
    for i in S:
        if i in matches.values():
            if stack and matches[stack[-1]] == i:
                stack.pop()
            else:
                return 0
        else:
            stack.append(i)

    return int(not stack)
solution("TT")
c[0]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16434892541087232, 'fraction_numerical': 0.006321112515802781, 'mean_word_length': 1.498422712933754, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '618507', 'license': 'MIT', 'n_tokens_mistral': 292, 'n_tokens_neox': 284, 'n_words': 70, 'path': 'fun_coding/codility/7_Brackets(StacksandQueues).ipynb', 'repo_name': 'kangyeolyoun2/python-coding-practice-folder', 'size': '791'}