Answers for "hackerrank between two sets solution in python"

1

between two sets problem hackerrank solution in c

#include<stdio.h>
int main() {
    int n,t,flag1,flag2,j,total=0,i;
    int m;
    scanf("%i %i", &n, &m);
    int a[n],b[m];
    for (i = 0; i < n; i++) 
       scanf("%i",&a[i]);
    
    for (i = 0; i < m; i++) 
       scanf("%i",&b[i]);
    
    for(t=n;t<=b[0];t++)
    {
        flag1=0;
        flag2=0;
        for(i=0;i<n;i++)
        {
            if(t%a[i] !=0)
            {
                flag1=1;
                break;
            }
        }
        if(flag1 == 0)
        {
            for(j=0;j<m;j++)
            {
                if(b[j]%t !=0)
                {
                    flag2=1;
                    break;
                }
            }
        }
        if(flag1 == 0 && flag2 == 0)
            total++;
    }
    printf("%d\n", total);
    return 0;
}
Posted by: Guest on July-06-2020
0

hackerrank between two sets solution in python

# Complete the 'getTotalX' function below.

def getTotalX(a, b):
    maxA = max(a)
    minB = min(b)
    count = 0
    for num in range(maxA, minB + 1):
        left = all([num % numA == 0 for numA in a])
        right = all([numB % num == 0 for numB in b])
        count += left * right
    return count
Posted by: Guest on March-27-2021

Code answers related to "hackerrank between two sets solution in python"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language