Positive Dominant

Published by Helen Yu in

An array is positive dominant if it contains strictly more unique positive values than unique negative values. Write a function that returns true if an array is positive dominant.

Examples

is_positive_dominant([1, 1, 1, 1, -3, -4]) ➞ false
# There is only 1 unique positive value (1).
# There are 2 unique negative values (-3, -4).

is_positive_dominant([5, 99, 832, -3, -4]) ➞ true

is_positive_dominant([5, 0]) ➞ true

is_positive_dominant([0, -4, -1]) ➞ false

Notes

0 counts as neither a positive nor a negative value.

Watch a quick demo on how Edabit works.