Skip to content

Commit 726beb7

Browse files
committed
Fix hang with new LeetCode parser
1 parent df07563 commit 726beb7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

leetcode/parser.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void print_impl(ostream &os, const T &val, bool write_newline) {
126126
// supports up to 10 arguments debugging at one time
127127
#define dbg(...) CONCAT(DBG_, NUM_ARGS(__VA_ARGS__))(__VA_ARGS__), cerr << '\n';
128128

129-
template <typename T> T parse(istream &is = cin) {
129+
template <typename T> T parse(istream &is) {
130130
T ans;
131131
char ch;
132132
is >> ws;
@@ -268,7 +268,8 @@ void run(R (Solution::*fn)(Ts...)) {
268268
get<0>(args) = Solution{};
269269
try {
270270
[&]<size_t... Idx>(index_sequence<Idx...>) {
271-
([&]() { get<Idx + 1>(args) = parse<decay_t<Ts>>(); }(), ...);
271+
([&]() { get<Idx + 1>(args) = (cin >> ws, parse<decay_t<Ts>>(cin)); }(),
272+
...);
272273
}(index_sequence_for<Ts...>{});
273274
} catch (const exception &e) {
274275
cerr << "Error: " << e.what() << endl;

0 commit comments

Comments
 (0)