Skip to content

Commit 578a42c

Browse files
authored
Create 1640-check-array-formation-through-concatenation.js
1 parent c240c50 commit 578a42c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {number[]} arr
3+
* @param {number[][]} pieces
4+
* @return {boolean}
5+
*/
6+
const canFormArray = function(arr, pieces) {
7+
const str = arr.join('-')
8+
for(let i = 0, len = pieces.length; i < len; i++) {
9+
const tmp = pieces[i].join('-')
10+
if(str.indexOf(tmp) === -1) return false
11+
}
12+
return true
13+
};

0 commit comments

Comments
 (0)