def convert_int_to_bin(dec_num): s = Stack() while dec_num > 0: rem = dec_num % 2 s.push(rem) dec_num = dec_num // 2 binary = "" while len(s.get_stack()) > 0: binary = binary + str(s.pop()) return binary
def isBalancedSet(bracket_set): s = Stack() for bracket in bracket_set: cb = opening_brackets.get(bracket) ob = closing_brackets.get(bracket) if cb is not None: s.push(bracket) elif ob is not None: pb = s.pop() if ob == pb: continue else: return -1 else: return None return -1 if len(s.get_stack()) > 0 else 1