migratory bird problem in javascript
function MigratoryBird(arr){
let map = {}, maxCount = 0, output = [];
for (let i = 0; i < arr.length; i++) {
if (!map[arr[i]]) {
map[arr[i]] = 1;
} else {
map[arr[i]] += 1;
}
// getting max count
if (map[arr[i]] > maxCount) {
maxCount = map[arr[i]];
}
}
for (let j = 0; j < arr.length; j++) {
if (map[arr[j]] === maxCount) {
output.push(arr[j]);
}
}
return Math.min(...output);
}
Also in JavaScript:
- js copy array into another
- javascript int values
- discord.js bad word filter
- how to clear array in javascript
- add coustom handlechange fprmik
- get current directory vbscript
- javascript document load
- how to format json file in vs code
- how to add js in flask
- javascript find a digit in str
- delay in javascript
- javascript go to previous page
- react native navigation shared element
- js remove if
- javascript switch case regex
- react native slow performance after load iamges
- Prevent Multiple Form Submissions With JQuery
- jquery get ip
- .env not working on react
- expressjs swagger yaml
- rxjs mapto vs tap
- how to set up a success message show up if form is submitted in react hooks
- javascript detect time on page
- javascript element by class