Using
if(array[i]=="1")
passes all test cases (in Hacker rank).
But
if(array[i]=='1')
doesn't pass all the test cases.
What are the differences between ""
and ''
in Python?
Why does the latter take more time?
Here are the screenshots:
The code:
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'acmTeam' function below.
#
# The function is expected to return an INTEGER_ARRAY.
# The function accepts STRING_ARRAY topic as parameter.
#
def acmTeam(topic):
m=0
count=0
for i in range(len(topic)):
for j in range(i+1,len(topic)):
k=(bin(int(topic[i],2) | int(topic[j],2)))[2:]
# if k>m:
# m=k
# count=1
# elif m==k:
# count+=1
val=0
for ind in range(len(k)):
if (k[ind]=="1"):
val+=1
if val>m:
count=1
m=val
elif val==m:
count+=1
return [m,count]