Skip to content

Commit 7dda070

Browse files
committedFeb 24, 2017
4.9 BST Sequences: simplification
·
v1.0.01.0.0
1 parent 4f76565 commit 7dda070

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed
 

‎src/trees-and-graphs/bst-sequence.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,9 @@ function weave(prefix = [], arrays1 = [[]], arrays2 = [[]]) {
4545
arrays1.forEach((array1) => {
4646
arrays2.forEach((array2) => {
4747

48-
if(!array1.length && !array2.length) {
49-
result.push(prefix);
48+
if(!array1.length || !array2.length) {
49+
result = result.concat([prefix.concat(array1, array2)]);
5050

51-
} else if(!array1.length) {
52-
result = result.concat(weave(prefix.concat(array2), [array1], []));
53-
54-
} else if(!array2.length) {
55-
result = result.concat(weave(prefix.concat(array1), [], [array2]));
5651
} else {
5752
// weave the arrays
5853
array1.forEach(function (_, i, array) {

0 commit comments

Comments
 (0)
Please sign in to comment.