Skip to content

Instantly share code, notes, and snippets.

View christianbiring1's full-sized avatar
🎯
Focusing

Christian Biringanine christianbiring1

🎯
Focusing
View GitHub Profile
@Stefanacef
Stefanacef / Migratory Birds | Solution | JavaScript.js
Last active May 26, 2023 12:12
Solution for "Migratory Birds" in Hackerrank
const arr=[1, 2, 3, 4,5, 4, 3, 2, 1, 3, 4]
function migratoryBirds(arr) {
let objectArr=arr.reduce((obj, b)=> {
obj[b] = ++obj[b] || 1;
return obj;
}, {});
// console.log(objectArr)
const maxVal=Math.max(...Object.values(objectArr))
const num=Object.keys(objectArr).find(key => objectArr[key] === maxVal)