Generate an array A, such that gcd of all its contiguous subarray is present in the given array G. If it is not possible to generate such an array then print -1. Read more →
C++ Programs
155 postsGiven a Complete Binary Tree, the task is to print the elements in the Clockwise Triangular traversal order. Examples : Input : 1 / \ 2 3 / \ / \ 4 Read more →
Delete an element from the Set by passing its value : Approach : In this method, an element is deleted by using the erase function and calling it with the value of Read more →
Given N coins initially all tails up (let say represented by ‘0’) and a number of queries Q. There are two types of queries. Update: 1) Given indices of a range [L, Read more →
You are given two boxes. The first box is empty while in the second, there are 3 piles of coins. Whenever you choose a pile of X coins (x>=1) from the second Read more →
Given a 2D Grid consisting of integer values the task is to check whether there is a cycle in the grid or not . A valid cycle in the grid should follow Read more →
Given two natural numbers N1 and N2.The task is to find the maximum possible sum after swapping of a single digit between two given natural numbers. Examples : Input : N1=123 N2=998 Read more →
Given a disconnected graph G with N vertices and M edges and cost[] for all the vertices, the task is to add edges to G to make it connected and to add Read more →
Given two arrays with unequal sizes, you have to take one element from first array(say a) and one element from array 2(say b). If the sum of a and b is a Read more →
You are given a positive integer n, and an array a of positive integers. Find number of such pairs (i,j) such that i<j and ai & aj ≥ ai ^ aj, where Read more →