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
|
3178 Discussions
|
Please Login in order to post a comment
def plusMinus(arr): # Write your code here positive_count = 0 negative_count = 0 zero_count = 0 for num in arr: if num > 0: positive_count += 1 elif num < 0: negative_count += 1 else: zero_count += 1 positive_ratio = positive_count / n negative_ratio = negative_count / n zero_ratio = zero_count / n print(f"{positive_ratio:.6f}") print(f"{negative_ratio:.6f}") print(f"{zero_ratio:.6f}")
Typescript:
javascript:
function plusMinus(arr) { let positivo = 0; let negativo = 0; let cero = 0;
}
Video - Java - Time O(n); Space O(1) https://www.youtube.com/watch?v=YRht_UcDIK4