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.
This solution is best using the brute-force approach — it's shorter, faster, and cleaner vs LCM and GCD traditional.
defgetTotalX(a,b):# Write your code herecount=0forxinrange(max(a),min(b)+1):# Check if x is divisible by all elements in aifall(x%ai==0foraiina):# Check if x divides all elements in bifall(bi%x==0forbiinb):count+=1returncount
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →
This solution is best using the brute-force approach — it's shorter, faster, and cleaner vs LCM and GCD traditional.