We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defplusMinus(arr:Array[Int]){// Write your code herevaln=arr.lengthvarpositiveCount,negativeCount,zeroCount=0arr.map(elem=>{if(elem>0)positiveCount=positiveCount+1elseif(elem<0)negativeCount=negativeCount+1elsezeroCount=zeroCount+1})valpositiveRatio=positiveCount.toFloat/nvalnegativeRatio=negativeCount.toFloat/nvalzeroRatio=zeroCount.toFloat/nprintln(f"$positiveRatio%.6f")println(f"$negativeRatio%.6f")println(f"$zeroRatio%.6f")}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
Scala