INTRODUCTORY PROBLEMS 1 . WEIRD ALGORITHM SOLUTION: #include < bits / stdc ++. h > using namespace std ; int main (){ long long n ; //beacuse n can be greater than max size of int. cin >> n ; while ( n != 1 ){ // loop will break when n become 1. cout << n << " " ; if ( n & 1 ) n = n * 3 + 1 ; // when n is odd. else n = n / 2 ; // when n is even. } cout << "1" ; } 2 . MISSING NUMBER SOLUTION : LOGIC: just sum all the inputs and subtract from total sum(n*(n+1)/2). #include < bits / stdc ++. h > using namespace std ; int main (){ long long n , s , sum = 0 ; cin >> n ; for ( long long i = 0 ; i < n - 1 ; i ++){ cin >> s ; sum += s ; //sum all the inputs. } ...
JUNE LONG CHALLENGE Problem code : Contain /* Algorithm :- --> We will create concentric hulls as many as possible. This can be done using a tracking array to keep track of points which are still unused and passing. it again in convex hull function We will do this until our track array becomes empty . Algorithm used :- Finding convex hull using graham scan in O(nlogn) ( For AC ) Finding convex hull using jarvis march in O(n^2) ( For 35 points ) --> Then we will memoize all these convex hulls. Now we cant create hulls for each query as it will result in O(q*n^2) ...