Count 5s and Win

Published by BijogFc24 in

Arun is obsessed with primes, especially five. He considers a number to be luckiest if it has the highest number of five in it. If two numbers have the same frequency of five, Arun considers the larger of them to be luckiest, and if there is no five in any number, the first given number is considered luckiest. Help him choose the luckiest number.

Examples

getLuckiest([5, 12, 55, 11]) ➞ 55

getLuckiest([5, 12, -55,  11]) ➞ -55

getLuckiest([515, 1255, -55,  1]) ➞ 1255

getLuckiest([44, 12, 7, 40]) ➞ 44

Notes

Return null if given an empty array.

Watch a quick demo on how Edabit works.