Posts

Showing posts from August, 2021

Solution of 'Variable Sized Arrays' (HackerRank)

  Hi guys, here's my solution of the question-'Variable Sized Arrays' from HackerRank. Again, if you guys have any doubts regarding my code, any suggestions for my code or blog, do comment below. TY and Happy Coding! #include   <bits/stdc++.h> using   namespace   std ; int   main () {      int   n , q ;      cin >> n >> q ;      vector < int >  v [ n ];      for ( int   i = 0 ; i < n ; i ++){          int   Q ;          cin >> Q ;          for ( int   j = 0 ; j < Q ; j ++){              int   x ;              cin >> x ;          ...

Solution of 'FIGUREFUL' (SPOJ)

  Hey everyone! Here's my solution of the question- 'FIGUREFUL' from SPOJ. Do comment your suggestions for my blogs and code. TY and Happy coding! question link: https://www.spoj.com/problems/ACMCEG2B/ #include   <bits/stdc++.h> using   namespace   std ; int   main () {      map < pair < int , int >,  string >  code ;      int   n , q ;      cin >> n ;      for ( int   i = 0 ; i < n ; i ++){          int   x , y ;          string   s ;          cin >> x >> y >> s ;          code [ { x , y } ] = s ;     }      cin >> q ;      string   name [ q ];      for ( in...

Solution of 'Less or Equal' (Codeforces)

  Hey guys! Here's my solution of question-'Less or Equal' from Codeforces. I am looking forward to your suggestions for my code or blog. So do comment. TY and Happy coding! question link: https://codeforces.com/contest/977/problem/C #include   <bits/stdc++.h> #define   pair   < int,int >  pp using   namespace   std ; int   main () {      int   n , k ;      cin >> n >> k ;      vector < int >  vec ;      for ( int   i = 0 ; i < n ; i ++){          int   x ;          cin >> x ;          vec . push_back ( x );     }      sort ( vec . begin (), vec . end ());      if (( k != 0 )&&( vec [ k - 1 ] != vec [ k ] )) { cout ...

Solution of 'Three Friends' (Codeforces)

 Hello everyone! Here's my solution of the question-'Three Friends' from Codeforces. Any suggestion for me is highly appreciated. Happy Coding! question link: https://codeforces.com/problemset/problem/1272/A #include   <bits/stdc++.h> #define   long  long long int using   namespace   std ; int   main () {      int   q ;      cin >> q ;      int   d [ q ];      for ( int   m = 0 ; m < q ; m ++){          int   a , b , c , min = 1999999999 ;          cin >> a >> b >> c ;          int   a1 [ 3 ]={ a + 1 , a , a - 1 };          int   b1 [ 3 ]={ b + 1 , b , b - 1 };          int   c1 [ 3 ]={ c + 1 , c...

Solution of 'Choose Two Numbers' (Codeforces)

Hola amigos! Here's my solution of the question- 'Choose Two Numbers' from Codeforces. If you guys have any suggestions for my code or blog or anything, do comment. TY and Happy Coding! question link: https://codeforces.com/problemset/problem/1206/A #include   <bits/stdc++.h> using   namespace   std ; int   main () {      int   n , m , f = 0 ;      cin >> n ;      vector < int >  a ;      for ( int   i = 0 ; i < n ; i ++){          int   x ;          cin >> x ;          a . push_back ( x );     }      cin >> m ;      vector < int >  b ;      for ( int   i = 0 ; i < m ; i ++){       ...

Solution of 'Tom Riddle's Diary' (Codeforces)

  Hey everyone! Here's my solution of the question- Tom Riddle's Diary from Codeforces. If you guys have any suggestion do comment. T.Y. and Happy coding. question link: https://codeforces.com/contest/855/problem/A #include   <bits/stdc++.h> using   namespace   std ;   int   main () {      vector < string > v ;      int   n ;      cin >> n ;      string   a [ n ];      for ( int   i = 0 ; i < n ; i ++){          string   p ;          cin >> p ;          v . push_back ( p );          int   h = count ( v . begin (),  v . end (), p );          if ( h == 1 )  a [ i ] = "NO" ;     ...

Solution of 'Maps-STL' (Hackerrank)

So, here's my solution of the question- Maps-STL of Hackerrank. If you guys have any suggestions, do comment. Thank you and Happy coding. link: https://www.hackerrank.com/challenges/cpp-maps/problem #include   <cstdio>   #include   <cmath> #include   <vector> #include   <iostream> #include   <set> #include   <map> #include   <algorithm> using   namespace   std ; int   main () {      int   q ;      cin >> q ;      int   a [ q ];      map < string , int >  mark ;      for ( int   i = 0 ; i < q ; i ++){          cin >> a [ i ];          if ( a [ i ]== 1 ){              string   p ;     ...