LeetCode题解(1117):H2O生成(Python)
题目:原题链接(中等)标签:多线程解法时间复杂度空间复杂度执行用时Ans 1 (Python)O(N)O(N)O(N)O(1)O(1)O(1)56ms (33.33%)Ans 2 (Python)Ans 3 (Python)解法一:class H2O: def __init__(self): self.count = 0 self.s1 = threading.Semaphore(2)