Skip to content

Commit b7d7a37

Browse files
Fixed broken problem (ignacio-chiazzo#25)
1 parent 93fed5d commit b7d7a37

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

LeetcodeProblems/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,8 @@ var TreeNode = function(val) {
6161
this.left = this.right = null;
6262
}
6363

64-
console.log(
65-
buildTree(
66-
[3,9,20,15,7],
67-
[9,3,15,20,7]
68-
)
69-
);
64+
var main = function() {
65+
console.log(buildTree([3,9,20,15,7], [9,3,15,20,7]));
66+
}
7067

7168
module.exports.main = main

Main.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ var main = async function() {
99
for(i in problems) {
1010
console.log("Solving: " + problems[i] + ":");
1111
const problem = require(PROBLEMS_FOLDER + problems[i]);
12-
problem.main();
13-
console.log("End of the solution for : " + problems[i] + ",\n\n");
12+
if (typeof(problem.main) !=='undefined') {
13+
problem.main();
14+
console.log("End of the solution for : " + problems[i] + ",\n\n");
15+
} else {
16+
console.warn(problem, "The problem " + problems[i] + " doesn't have a main method implemented.");
17+
}
1418
}
1519
} catch (error) {
1620
throw new Error(error);
@@ -23,8 +27,8 @@ var loadProblems = () => {
2327
if (error) {
2428
reject(error);
2529
} else {
26-
problems = files.filter(item => !(REGEX_PATTERN_HIDDEN_FILES).test(item));
27-
resolve(problems);
30+
problems = files.filter(item => !(REGEX_PATTERN_HIDDEN_FILES).test(item));
31+
resolve(problems);
2832
}
2933
})
3034
});

0 commit comments

Comments
 (0)