Skip to content

Commit d7560fe

Browse files
committed
https://leetcode.cn/problems/print-in-order/
1 parent eb37fef commit d7560fe

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2582,4 +2582,6 @@ https://leetcode.cn/problems/split-a-circular-linked-list/
25822582

25832583
https://leetcode.cn/problems/ipo
25842584

2585+
https://leetcode.cn/problems/print-in-order/
2586+
25852587
</details>

ipo/index.ixx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ using std::priority_queue;
1010
using std::vector;
1111
namespace leetcode_test::ipo {
1212
export class Solution {
13-
public:
14-
int findMaximizedCapital(int k, int w, vector<int>& profits,
15-
vector<int>& capital)
16-
{
13+
public:
14+
int findMaximizedCapital(int k, int w, vector<int> &profits,
15+
vector<int> &capital) {
1716
int n = profits.size();
1817
int curr = 0;
1918
priority_queue<int, vector<int>, less<int>> pq;
@@ -39,4 +38,4 @@ public:
3938
return w;
4039
}
4140
};
42-
}
41+
} // namespace leetcode_test::ipo

print-in-order/index.ixx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module;
2+
#include <functional>
3+
#include <future>
4+
#include <thread>
5+
using std::function;
6+
using std::future;
7+
export module leetcode_test.print_in_order.Foo;
8+
namespace leetcode_test::print_in_order {
9+
export class Foo {
10+
private:
11+
std::promise<void> outpromise2;
12+
std::promise<void> outpromise3;
13+
14+
public:
15+
Foo() {}
16+
17+
void first(function<void()> printFirst) {
18+
19+
// printFirst() outputs "first". Do not change or remove this line.
20+
printFirst();
21+
outpromise2.set_value();
22+
}
23+
24+
void second(function<void()> printSecond) {
25+
future<void> fu = outpromise2.get_future();
26+
fu.get();
27+
// printSecond() outputs "second". Do not change or remove this line.
28+
printSecond();
29+
outpromise3.set_value();
30+
}
31+
32+
void third(function<void()> printThird) {
33+
future<void> fu = outpromise3.get_future();
34+
fu.get();
35+
// printThird() outputs "third". Do not change or remove this line.
36+
printThird();
37+
}
38+
};
39+
} // namespace leetcode_test::print_in_order

0 commit comments

Comments
 (0)