Set .difference() Operation Hackerrank Solution in Python 3 July 07, 2019 a=int(input()) set1=set(map(int,input().split())) b=int(input()) set2=set(map(int,input().split())) set3=set1.difference(set2) print(len(set3)) Share Get link Facebook X Pinterest Email Other Apps Share Get link Facebook X Pinterest Email Other Apps Comments
Migratory Birds HackerRank Solution in C May 03, 2019 #include< stdio.h > int main() { long int n,i,b[ 10000 ],j,count= 0 ,t,k; long int a[ 100000 ],c[ 100000 ],p[ 100000 ]; scanf( "%ld" ,&n); for (i= 0 ;i<n;i++) { scanf( "%ld" ,&a[i]); } for (i= 0 ;i<n;i++) { if (a[i]== 1 ) { b[ 1 ]++; } if (a[i]== 2 ) { b[ 2 ]++; } if (a[i]== 3 ) { b[ 3 ]++; } if (a[i]== 4 ) { b[ 4 ]++; } if (a[i]== 5 ) { b[ 5 ]++; } } int max=b[ 1 ]; for (j= 1 ;j<= 5 ;j++) { if (max<b[j]) { max=b[j]; } } long int z= 1 ; for (j= 1 ;j<= 5 ;j++) { if (max==b[j]) { c[j]=j; count++; t=j;... Read more
String Split and Join Hackerrank Python Solution July 07, 2019 def split_and_join(line): line=line.split() line= '-' .join(line) return line if __name__ == '__main__' : line = input () result = split_and_join(line) print (result) Read more
Birthday Chocolate HackerRank Solution in C April 30, 2019 #include< stdio.h > int main() { int n,i,a[ 1000 ],dt,m,temp,count= 0 ,sum= 0 ,j; scanf( "%d" ,&n); for (i= 0 ;i<n;i++) { scanf( "%d" ,&a[i]); } scanf( "%d%d" ,&dt,&m); for (i= 0 ;i<n;i++) { sum= 0 ; temp= 0 ; for (j=i;j<n;j++) { if (temp<m) { sum=sum+a[j]; temp++; } } if (sum==dt) { count++; } } printf( "%d" ,count); return 0 ; } Read more
Comments
Post a Comment