tuhinmaji314
BAN USER
Comments (4)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
def isContiguous(arr):
if len(arr)==0:
return False
mini=min(arr)
maxi=max(arr)
for i in range(mini,maxi+1):
if i not in arr:
return False
return True
Comment hidden because of low score. Click to expand.
0
of 0 vote
def isAnagram(s1,s2):
if len(s1)!=len(s2):
return False
d={}
for x in s1:
if x not in d:
d[x]=1
else:
d[x]+=1
for x in s2:
if x not in d or d[x]==0:
return False
else:
d[x]-=1
return True
Comment hidden because of low score. Click to expand.
0
of 0 vote
def primeSum(n):
isPrime=[True]*(n+1)
isPrime[0]=False
isPrime[1]=False
p=2
while p*p<=n:
if isPrime[p]==True:
for i in range(2*p,n+1,p):
isPrime[i]=False
p+=1
res=0
for i in range(2,n+1):
if isPrime[i]==True:
res+=i
return res
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
- tuhinmaji314 October 24, 2019