import unittest class Solution: def isvalid(self, s:str) -> bool: matching_brackets = { ")": "(", "]": "[", "}": "{", } stack: list[str] = [] for bracket in s: if bracket in "([{": stack.append(bracket) continue if bracket not in matching_brackets: return False if not stack or stack[-1] != matching_brackets[bracket]: return False stack.pop() return not stack class SolutionTest: def __init__(self): self.Solution = Solution() def run(self): test_cases = [ ("", True), ("()", True), ("(){}[]", True), ("(({}))", True), ("(", False), (")", False), ("(((", False), ("{[]}", False), ] for brackets, expected in test_cases: actual = self.Solution.isvalid(brackets) assert actual == expected, ( f"Ошибка для {brackets!r}" f"Хотели получить {expected}, а получили {actual}" ) print(f"Все тесты пройдены: {len(test_cases)}") if __name__ == "__main__": SolutionTest().run()
Machine Learning / AI
3611
0
Senior
145
Describe step-by-step the path of a user message through an LLM during inference — from chat to response, including architectural details of Transformer.
Senior
145
What AI tools do you use daily?
Senior
139
Why does caching of exact user queries usually provide limited business value, and what exactly do you mean by caching responses?
Senior
137
How long did the search/full response cycle take in the RAG system?
Senior
133
Tell about your projects: what exactly did you do personally, in detail technically?
Senior
132
What is the dimensionality of logits and how is a token derived from them?
Senior
131
What does an LLM output at each inference step?
Senior
131