[Algorithm] Between Two Sets
- Hackerrank
- Algorithm
- Easy
- Link to Question
def getTotalX(a, b):
# Write your code here
# looking at the constraints, we should be able to brute force it
# (might / probably exist better solutions...)
works = []
for i in range(max(a), min(b)+1):
skip = False
for j in a:
if i % j != 0:
skip = True
break
if not skip:
for j in b:
if j % i != 0:
skip = True
break
if not skip:
works.append(i)
return len(works)
Leave a comment