☎️ "Extraordinary claims require extraordinary evidence." - Carl Sagan
arr.forEach((v) => { if (count === 0) { candidate = v; } if (candidate === v) { count += 1; } else { count = 0; } if (count >= arrSize) { ret = ‘majority is: ‘ + v; break; } });
return ret;
}
I personally think I could do it in a more efficient way (since this is, worst case, O(n)), kind of like they’re mentioning here, but this is what I came up with so far. :)
On to this week’s question!
Given an integer array and two numbers x and y, print x numbers from the array, such that difference between any two pairs is divisible by y. If there are no x numbers, then print -1.
Example:
differencePair([1, 8, 4], 2, 3) > 1 4
Explanation: the difference between 1 and 4 is divisible by 3
Cool things from around the internet
What bullets do to bodies
The History of the Ampersand
Tony Fadell Gets Back at Silicon Valley - From Paris
DZ60 | EnjoyPBT Hangul
Joke
A funeral service is held for a woman who just passed away.
As the pallbearers carry the casket out, they accidentally bump into a wall, and they hear a faint moan.
They open the casket and find that the woman is actually alive.
She lives for 10 more years and then dies.
They have another funeral for her. At the end of the service, the pallbearers carry out the casket.
As they are walking, the husband cries out, “Watch out for the wall!”
That’s all from me this week friends, have a good one! Be safe, make good choices, and sing some show tunes.
cassidoo