HTMLify

LeetCode - Print in Order - Python
Views: 13 | Author: abh
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()

Comments