Given an integer array arr[] (0 < arr[i] < 106) of size N, the task is to find the LCM of unique elements of the array. If there is no unique element Read more →
Algorithms
6 postsWe have a set of numbers from 1 to N. In one operation we are allowed to replace A and B by rounded up value of (A+B)/2. We can perform this procedure Read more →
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 →
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 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 →
You are given an integer array which is sorted in non-decreasing order. Build and return an integer array result with the same length as the integer array such that result[i] is equal 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 →
A string is called happy if it does not have any of the strings ‘aaa’, ‘bbb’ or ‘ccc’ as a substring. Given three integers a, b and c, return any string s, Read more →