presentation
presentation

Plus Minus

November 15, 2019 • ☕️ 1 min read
algorithm/hackerrank

출처

// Complete the plusMinus function below.
function plusMinus(arr) {
  const length = arr.length
  const count = [0, 0, 0]

  arr.forEach(n => {
    if (n > 0) count[0]++
    else if (n < 0) count[1]++
    else count[2]++
  })

  count.forEach(c => process.stdout.write((c / length).toFixed(6) + "\n"));