HTMLify
LeetCode - Print in Order - Python
Views: 317 | Author: abh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | from time import sleep class Foo: def __init__(self): self.last_print = 0 def first(self, printFirst: 'Callable[[], None]') -> None: while self.last_print != 0: sleep(0.01) # printFirst() outputs "first". Do not change or remove this line. printFirst() self.last_print = 1 def second(self, printSecond: 'Callable[[], None]') -> None: while self.last_print != 1: sleep(0.01) # printSecond() outputs "second". Do not change or remove this line. printSecond() self.last_print = 2 def third(self, printThird: 'Callable[[], None]') -> None: while self.last_print != 2: sleep(0.01) # printThird() outputs "third". Do not change or remove this line. printThird() |