Skip to content
Onsite

Plus Minus

EasyP3Coding

Return three strings: the fraction of elements that are positive, the fraction that are negative, and the fraction that are zero, in that order. Each fraction is count / n formatted with exactly six digits after the decimal point.

For an empty array return ["0.000000", "0.000000", "0.000000"].

Example 1

Input
nums = [-4,3,-9,0,4,1]
Output
["0.500000","0.333333","0.166667"]

Example 2

Input
nums = [1,2,3]
Output
["1.000000","0.000000","0.000000"]

Example 3

Input
nums = []
Output
["0.000000","0.000000","0.000000"]

Constraints

  • 0 <= nums.length <= 10^5
  • -10^9 <= nums[i] <= 10^9

Hints

Run checks the 3 visible tests, Submit all 10.