#c++ #basic
LCM and GCD in c++
LCM and GCD in c++ #include <iostream> int gcd ( int a , int b ) { if ( b == 0 ) { return a ; } return gcd ( b , a % b ); } int lcm ( int x , int y ) { return ( x * y ) / gcd ( x , y ); } int m…
#c++ #basic
LCM and GCD in c++ #include <iostream> int gcd ( int a , int b ) { if ( b == 0 ) { return a ; } return gcd ( b , a % b ); } int lcm ( int x , int y ) { return ( x * y ) / gcd ( x , y ); } int m…
Count 1's in a sorted Binary Array // count 1's in a sorted Binary array # include < iostream > int Co…
Read moreFinding the Last Occurrence of the element Finding the Last Occurrence of the element in an given arra…
Read moreBINARY SEARCH # include < iostream > int BinarySearch ( int arr [], int n , int x ) { int low = 0…
Read more# include < iostream > int findMajority ( int arr [], int n ) { // here the code goes int res = …
Read moreFinding leaders in an array Here I have written the Two approach one is naive approach which will take O(n^2) time com…
Read moreMoving Zeros to end in an array # include < iostream > void display ( int arr [], int n ) { std :: cout …
Read moreReverse an array arr[] = {a, b, c, .......}; # include < iostream > int reverse ( int arr [], int size ) { …
Read more
Social Plugin