Posts

ACM ICPC Team

 Question :- https://www.hackerrank.com/challenges/acm-icpc-team/problem Solution in C language :- #include< stdio.h > #include< string.h > int   main (){      int   n , m ;      scanf ( "%d%d" ,& n ,& m );      char   str [ n ][ m ];      int   i , j ;      for ( i = 0 ; i < n ; i ++){          scanf ( "%s" , str [ i ]);      }      int   c = 0 , k , cm = 0 , z = 1 ;      for ( i = 0 ; i < n ; i ++){          for ( j = i + 1 ; j < n ; j ++){              c = 0 ;              for ( k = 0 ; k < m ; k ++){            ...

Jumping On The Clouds

 Question :- https://www.hackerrank.com/challenges/jumping-on-the-clouds/problem Solution in C language :- #include< stdio.h > main () {      int   n , i , sum = 0 ;      scanf ( "%d" ,& n );      int   a [ n ];      for ( i = 0 ; i < n ; i ++)      scanf ( "%d" ,& a [ i ]);      for ( i = 0 ; i < n ;)      {          if ( a [ i + 1 ]== 0 && a [ i + 2 ]== 1 )          {              i = i + 1 ;              sum ++;          }          else          {        ...

Repeated String

 Question :- https://www.hackerrank.com/challenges/repeated-string/problem Solution in C language :- #include< stdio.h > #include< string.h > int   main (){      long   long   int   n ;      char   s [ 100 ];      scanf ( "%s %lld" , s ,& n );      int   len = strlen ( s );      long   long   int   i , a = 0 ;      for ( i = 0 ; s [ i ]!= ' \ 0 ' ; i ++){          if ( s [ i ]== 'a' )              a ++;      }      long   long   int   t = n / len , temp = n % len ;      t = t * a ;      if ( temp != 0 ){          for ( i = 0 ; i < temp ; i ++){    ...

Cut The Sticks

 Question :- https://www.hackerrank.com/challenges/cut-the-sticks/problem Solution in C language :- #include< stdio.h > int   main (){      int   n ;      scanf ( "%d" ,& n );      int   a [ n ], i ;      for ( i = 0 ; i < n ; i ++){          scanf ( "%d" ,& a [ i ]);      }      int   temp = a [ 0 ], j , t = n , c = 0 , d = 0 ;      printf ( "%d\n" , n );      for ( j = 0 ; j < t ; j ++){          temp = 1000 ;          for ( i = 0 ; i < n ; i ++){              if ( a [ i ]> 0 ){                  if ( temp > a [ i ]) ...

Library Fine

 Question :- https://www.hackerrank.com/challenges/library-fine/problem Solution in C language :- #include< stdio.h > int   main (){      int   d1 , d2 , m1 , m2 , y1 , y2 ;      scanf ( "%d%d%d%d%d%d" ,& d1 ,& m1 ,& y1 ,& d2 ,& m2 ,& y2 );      if ( d1 != d2   ||   m1 != m2   ||   y1 != y2 )      { if ( y1 >= y2 ){          if ( m1 > m2   &&   y1 == y2 ){              printf ( "%d" , 500 *( m1 - m2 ));          }          if ( m1 < m2   &&   y1 == y2 ){              printf ( "0" );          }      ...

Sherlock and Squares

 Question :- https://www.hackerrank.com/challenges/sherlock-and-squares/problem Solution in C language :- #include   < stdio.h > #include   < string.h > #include   < math.h > #include   < stdlib.h > int   main (){ int   a , b ; scanf ( "%d" ); while ( scanf ( "%d%d" ,& a ,& b )> 0 ){      printf ( "%d\n" ,( int )( floor ( sqrt ( b ))- ceil ( sqrt ( a ))+ 1 ));} return   0 ;}

Append and Delete

 Question :- https://www.hackerrank.com/challenges/append-and-delete/problem Solution in C language :- #include< stdio.h > #include< string.h > int   main (){      char   a [ 100 ], b [ 100 ];      int   k ;      scanf ( "%s" , a );      scanf ( "%s" , b );      scanf ( "%d" ,& k );      int   la = strlen ( a ), lb = strlen ( b ), i , j , h , c = 0 , temp = 0 ; //    printf("%d %d\n",la,lb);      if ( la > lb ){          j = lb ;          h = la ;      }      else {          j = la ;          h = lb ;      }      for ( i = 0 ; i < j ; i ++){ ...