Professional Documents
Culture Documents
Input: [2,1,3,1,1,1]
Output: [1]
// list = []
// map => {key => elm, value, freq}
// map => {key > freq > n / 3}
// return [list]
// else return []
// code structure
var findElement = function(nums) {
let response = []
let hMap = new Map();
let n = nums.length
return response;
};
nums = [2,1,3,1,1,1]
1. itration
hMap = {}
// ele = 2;
if hMAp is having the ele
hMap = {2: currentCount}
else
hMap = {2: 1}
hMap = {2: 1, 1: 4, 3: 1}
reponse = []
2. itration
if any hMap key is having a value > n / 2
add to reponse
// reponse.push(1)
else
// reponse is still empty
return reponse
Output: [1]
let obj = {
a : {
b : (a,b,c)=>a+b+c, // callback
c : (a,b,c) => a+b-c,
},
d : (a,b,c) => a-b-c
};
Create a function
Fn(obj)(1,1,1);
output
{
a : {
b : 3,
c : 1
}
d: -1
},
sum(1)(1)(1) => 3
console.log('1')
setTimeout(()=> console.log(2), 1000)
console.log('3')
console.log(new Promise (1));
// 1
// 3
// Pending<>(1)
// 2
// parse
// strigify
{
"name": "Aditya"
}
localStorage.setItem("name", "")
JSON.pase(localStorage.getItem("name"))
newArr = arr.myMap(ele)
function myMap(data) {
return
}
arr = []