Skip to content

Commit 21a5413

Browse files
committed
Day84 :)
1 parent 9ed6967 commit 21a5413

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Day84/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @param {number[]} arr
3+
* @param {number[][]} pieces
4+
* @return {boolean}
5+
*/
6+
var canFormArray = function (arr, pieces) {
7+
8+
9+
let map = {};
10+
11+
for (let p of pieces) {
12+
let data = p[0];
13+
if (!(data in map)) map[data] = [];
14+
map[data].push(...p)
15+
}
16+
17+
let res = [];
18+
for (let i = 0; i < arr.length; i++) {
19+
if (arr[i] in map) {
20+
res.push(...map[arr[i]])
21+
}
22+
}
23+
24+
console.log(res)
25+
return arr.join("") == res.join("")
26+
};

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,6 @@ If you are loving solving problems in leetcode, please contact me to enjoy it to
186186

187187
|Day 82| [289. Game of Life](https://leetcode.com/problems/game-of-life/) | [javascript]()|[:memo:](https://leetcode.com/problems/game-of-life/)|Medium|
188188

189-
|Day 83| [84. Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram/) | [javascript]()|[:memo:](https://leetcode.com/problems/largest-rectangle-in-histogram/)|Medium|
189+
|Day 83| [84. Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram/) | [javascript]()|[:memo:](https://leetcode.com/problems/largest-rectangle-in-histogram/)|Medium|
190+
191+
|Day 84| [1640. Check Array Formation Through Concatenation](https://leetcode.com/problems/check-array-formation-through-concatenation/) | [javascript]()|[:memo:](https://leetcode.com/problems/check-array-formation-through-concatenation/)|Easy|

0 commit comments

Comments
 (0)