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.
- Plus Minus
- Discussions
Plus Minus
Plus Minus
Sort by
recency
|
695 Discussions
|
Please Login in order to post a comment
C# Code static void plusMinus(List arr) { int total = arr.Count; int positive = 0, negative = 0, zero = 0; foreach (int num in arr) { if (num > 0) positive++; else if (num < 0) negative++; else zero++;
}
**JAVA **
int length = arr.size(); int countPositive = 0; int countNegative = 0; int countZeroes = 0;
Depending on the size of the dataset, it can use CompletableFuture or even a ThreadPool (in C# TPL for async and parallel tasks as well). But this task is quite simple, so it would not be required
public static void plusMinus(List arr) { var total = arr.Count(); var positives = arr.Where(p => p > 0).ToList(); Console.WriteLine(CalculateInputRatio(positives.Count, total));