We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
let contadorPiedrasPreciosas = 0
let piedras = []
const rocas = []
for (const rock of arr) {
for (const p of rock ) {
if (piedras.includes(p)) {
continue;
} else {
piedras.push(p)
}
}
rocas.push(piedras)
piedras = []
}
for (const r of rocas) {
for (const p of r) {
aparicionPiedras[p] = (aparicionPiedras[p] || 0) + 1
}
}
for (const p in aparicionPiedras) {
if (aparicionPiedras[p] === arr.length) {
contadorPiedrasPreciosas++;
}
}
return contadorPiedrasPreciosas``
`
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Gemstones
You are viewing a single comment's thread. Return to all comments →
`