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.
publicstaticvoidplusMinus(List<Integer>arr){// Write your code hereintpositiveRatio=0;intnegativeRatio=0;intzerosRatio=0;intlength=arr.size();for(intnum:arr){if(num==0){zerosRatio+=1;}elseif(num>0){positiveRatio+=1;}else{negativeRatio+=1;}}System.out.printf("%.6f%n",(double)positiveRatio/length);System.out.printf("%.6f%n",(double)negativeRatio/length);System.out.printf("%.6f%n",(double)zerosRatio/length);}
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 →