Posts

Showing posts with the label functions

Solution of 'Divisible Sum Pairs' (HackerRank)

Hi all! Here's my solution to the problem 'Divisible Sum Pairs' from HackerRank. #include <bits/stdc++.h> #define int long long #define pb push_back #define fi first #define se second #define pii pair < int,int > using namespace std ; int divisibleSumPairs ( int n , int k , vector < int > ar ) {     int cnt = 0 ;     for ( int i = 0 ; i < n ; i ++){         for ( int j = i + 1 ; j < n ; j ++){             if (( ar [ i ] + ar [ j ] )% k == 0 ) cnt ++;         }     }     return cnt ; } int32_t main () {     int n , k ;     cin >> n >> k ;     vector < int > num ;     for ( int i = 0 ; i < n ; i ++){         int x ;         cin >> x ;         num . pb ( x );     }     int res = divisibleS...

Solution of 'Breaking the Records' (HackerRank)

Hi all! Here's my solution to 'Breaking the Records' of HackerRank. #include <bits/stdc++.h> #define int long long #define pb push_back #define fi first #define se second #define pii pair < int,int > using namespace std ; vector < int > breakingRecords ( vector < int > scores ) {     int M = scores [ 0 ] , m = scores [ 0 ] , M_cnt = 0 , m_cnt = 0 ;     vector < int > temp ;     for ( int i = 0 ; i < scores . size (); i ++){         if ( scores [ i ] < m ){             m = scores [ i ] ;             m_cnt ++;         }         if ( scores [ i ] > M ){             M = scores [ i ] ;             M_cnt ++;         }     }     temp . pb ( M_cnt );     temp . pb ( m_cnt );   ...

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 ++){       ...