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.
- Prepare
- Algorithms
- Warmup
- Plus Minus
- Discussions
Plus Minus
Plus Minus
Sort by
recency
|
3222 Discussions
|
Please Login in order to post a comment
For Python:
def plusMinus(arr): # Write your code here positive = [] negative =[] zero = []
JavaScript
public static void plusMinus(List arr) { // Write your code here float zeroCount =0; float postiveCount=0; float negativeCount=0; for(int i=0;i0){ postiveCount++; } else { negativeCount++; } } System.out.println((postiveCount/arr.size())); System.out.println(negativeCount/arr.size()); System.out.println(zeroCount/arr.size()); }
FOR PYTHON 3
def plusMinus(arr): pcount = 0 ncount = 0 zcount = 0 for i in range(n): if arr[i] > 0: pcount = pcount+1 elif arr[i] < 0: ncount = ncount+1 elif arr[i] == 0: zcount = zcount+1 print(f"{pcount/n:.6f}") print(f"{ncount/n:.6f}")
print(f"{zcount/n:.6f}")
**Java **