Altar.io Interview Question

Javascript leetcode problem with random values