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"Errore per {brackets!r}" f"Volevamo ottenere {expected}, ma abbiamo ottenuto {actual}" ) print(f"Tutti i test sono passati: {len(test_cases)}") if __name__ == "__main__": SolutionTest().run()
Machine Learning / AI
3608
0
Senior
143
Quando i modelli di ragionamento e il calcolo al momento del test sono giustificati, e quando sono eccessivi?
Senior
142
Quali strumenti di IA usi quotidianamente?
Senior
139
Perché la memorizzazione nella cache delle query utente precise di solito offre un valore commerciale limitato e cosa intendevate esattamente con caching delle risposte?
Senior
135
Parlami dei tuoi progetti: cosa hai fatto esattamente, in dettaglio tecnico?
Senior
132
Quanto tempo è durata la ricerca / ciclo completo di risposta nel sistema RAG?
Senior
131
Qual è la dimensione dei logits e come si ottiene un token da essi?
Senior
131
Cosa ottiene LLM in output ad ogni passo di inferenza?
Senior
129