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.
def plusMinus(arr):
# Write your code here
cmax, cmin, czero=0,0,0
n=len(arr)
for i in arr:
if(i<0):
cmin=cmin+1
if(i>0):
cmax=cmax+1
if(i==0):
czero=czero+1
print(f"{cmax/n:.6f}\n{cmin/n:.6f}\n{czero/n:.6f}")
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 →
Here is a solution
def plusMinus(arr): # Write your code here cmax, cmin, czero=0,0,0 n=len(arr) for i in arr: if(i<0): cmin=cmin+1 if(i>0): cmax=cmax+1 if(i==0): czero=czero+1 print(f"{cmax/n:.6f}\n{cmin/n:.6f}\n{czero/n:.6f}")