updated readme
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// Author: Rodney Shaghoulian
|
||||
// Github: github.com/rshaghoulian
|
||||
// HackerRank: hackerrank.com/rshaghoulian
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
// Runtime: O(n)
|
||||
// Space Complexity: O(1)
|
||||
public class Solution {
|
||||
public static void main(String[] args) {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
int size = scan.nextInt();
|
||||
|
||||
double positives = 0;
|
||||
double negatives = 0;
|
||||
double zeroes = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
int value = scan.nextInt();
|
||||
if (value > 0) {
|
||||
positives++;
|
||||
} else if (value < 0) {
|
||||
negatives++;
|
||||
} else {
|
||||
zeroes++;
|
||||
}
|
||||
}
|
||||
scan.close();
|
||||
|
||||
System.out.println(positives / size);
|
||||
System.out.println(negatives / size);
|
||||
System.out.println(zeroes / size);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user