Intersection of Multiple Arrays | Leetcode 2248 | Strings | Contest 290 🔥🔥

preview_player
Показать описание
Here is the solution to "Intersection of Multiple Arrays" leetcode question. Hope you have a great time going through it.

🔥🔥🔥🔥👇👇👇 For discussion/feedback/humour/doubts/new openings

🔴 Checkout the series: 🔥🔥🔥

🔥🔥🔥 Leetcode Monthly Contest Playlist

PS : Please increase the speed to 1.25X
Рекомендации по теме
Комментарии
Автор

I donot know why I go for divide conquer, this one more simpler

abhishektiwari
Автор

var intersection = function (nums) {
let myMap = new Map()
let len = nums.length
let ans = []


for (let i = 0; i < nums.length; i++) {
for (let j = 0; j < nums[i].length; j++) {
if (myMap.has(nums[i][j])) {
myMap.set(nums[i][j], myMap.get(nums[i][j]) + 1)
} else {
myMap.set(nums[i][j], 1)
}
}
}

for (let [key, val] of myMap) {
if (val == len) {
ans.push(key)
}
}

return ans.sort((a, b) => a - b)
};
in JS

kiranm
join shbcf.ru