easiest solution || c-plus-plus || easy to understand || without using mutex 😎😎😎
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Foo {\n    promise<void> p1,p2;\npublic:\n    Foo() {\n        \n    }\n\n    void first(function<void()> printFirst) {\n        \n        // printFirst() outputs "first". Do not change or remove this line.\n        printFirst();\n        p1.set_value();\n    }\n\n    void second(function<void()> printSecond) {\n        \n        // printSecond() outputs "second". Do not change or remove this line.\n        p1.get_future().wait();\n        printSecond();\n        p2.set_value();\n    }\n\n    void third(function<void()> printThird) {\n        \n        // printThird() outputs "third". Do not change or remove this line.\n        p2.get_future().wait();\n        printThird();\n    }\n};\n```
['C++']