Arnab Chakraborty has Published 4293 Articles

Find a number x such that sum of x and its digits is equal to given n using C++.

Arnab Chakraborty

Arnab Chakraborty

Updated on 29-Oct-2019 11:16:34

95 Views

Here we will see one problem, where we take a number n, we have to find another value say x, such that x + digit sum of x is same as the given number n. Suppose the value of n is 21. This program will return a number x = ... Read More

Find amount to be added to achieve target ratio in a given mixture in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 24-Oct-2019 14:12:49

61 Views

Suppose we have a container with size X. It has a mixture of water and other liquid, the mixture has W% of water in it. We have to find how many water must be added to increase the ratio of water to Y%? If X = 125, W = 20 ... Read More

Find all pairs (a,b) and (c,d) in array which satisfy ab = cd in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 24-Oct-2019 13:23:15

229 Views

Suppose we have an array A, from that array, we have to choose two pairs (a, b) and (c, d), such that ab = cd. Let the array A = [3, 4, 7, 1, 2, 9, 8]. The output pairs are (4, 2) and (1, 8). To solve this, we ... Read More

Find all pairs (a, b) in an array such that a % b = k in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 24-Oct-2019 13:15:12

181 Views

Suppose we have an array A, from that array, we have to get all pairs (a, b) such that the a%b = k. Suppose the array is A = [2, 3, 4, 5, 7], and k = 3, then pairs are (7, 4), (3, 4), (3, 5), (3, 7).To solve ... Read More

Find all factorial numbers less than or equal to n in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 24-Oct-2019 13:08:48

1K+ Views

Here we will see how to print all factorial numbers less than or equal to n, a number N is said to be factorial number if it is a factorial of a positive number. So some factorial numbers are 1, 2, 6, 24, 120.To print factorial numbers, we do not ... Read More

Find All Duplicate Subtrees in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 24-Oct-2019 13:05:38

190 Views

Consider we have a binary tree. We have to find if there are some duplicate subtrees in the tree or not. Suppose we have a binary tree like below −There are two identical subtrees of size 2. In each subtree D, BD and BE both are also duplicate subtrees We ... Read More

Find a Symmetric matrix of order N that contain integers from 0 to N-1 and main diagonal should contain only 0’s in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 24-Oct-2019 13:02:41

135 Views

Here we will see how to generate one symmetric matrix of order N, and the elements of each row will contain numbers from 0 to N – 1. The diagonal elements will be 0 always.This task is easy, we will form a matrix of N x N, then for each ... Read More

Find a subset with greatest geometric mean in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 24-Oct-2019 12:58:09

151 Views

Here we have an array A with some elements. Our task is to find the subset where the geometric mean is maximum. Suppose A = [1, 5, 7, 2, 0], then the subset with greatest geometric mean will be [5, 7].To solve this, we will follow one trick, we will ... Read More

Find a point such that sum of the Manhattan distances is minimize in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 24-Oct-2019 12:55:39

667 Views

Suppose we have n different points in K dimension space, the value of n is in range (2, 105), and value of k in range (1 to 5). We have to determine the point such that the sum of Manhattan distance from resultant point to n points is minimized.The Manhattan ... Read More

Find a pair with the given difference in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 24-Oct-2019 12:53:24

406 Views

Consider we have an array A, there are n different elements. We have to find a pair (x, y) from the array A, such that the difference between x and y is same as given difference d. Suppose a list of elements are like A = [10, 15, 26, 30, ... Read More

Advertisements