Arnab Chakraborty has Published 4293 Articles

Check if a given number divides the sum of the factorials of its digits in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Oct-2019 11:14:52

165 Views

Suppose, we have an integer, we have to find if the number divides the sum of the factorial of its digits. Suppose a number is 19, the sum of factorial of digits is (1! + 9!) = 362881, this is divisible by 19.To solve this, we will take the number, ... Read More

Check if a given number can be represented in given a no. of digits in any base in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Oct-2019 11:11:40

160 Views

Suppose we have a number n, and number of digits d. We have to check whether the number n can be represented as d digit number in any base from 2 to 32. Suppose the number n is 8, and d = 4, then this can be represented as 1000 ... Read More

Check if a given mobile number is fancy in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Oct-2019 11:09:16

614 Views

We have a 10 digit mobile number, our task is to check whether the number is fancy number or not. There are three different conditions for a fancy number. If at least one is true, then the number is fancy. These conditions are like below −A single number occurs three ... Read More

Check if a cell can be visited more than once in a String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Oct-2019 10:58:43

183 Views

Suppose we have a string with dots (.) and a number, a dot indicates the cell is empty, and if there is a number x in any cell, it indicates that we can move x steps to the right or left within the string. Our task is to check whether ... Read More

Check if a binary tree is sorted levelwise or not in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Oct-2019 09:16:34

220 Views

Here we will see how to check a binary tree is level wise sorted or not. The level wise sorted binary tree will be look like below −In each level, the nodes are sorted from left to right, and each layer contains higher value than its previous level.We can solve ... Read More

Check if a Binary Tree contains duplicate subtrees of size 2 or more in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Oct-2019 09:13:10

229 Views

Consider we have a binary tree. We have to find if there are some duplicate subtrees of size 2 or more in the tree or not. Suppose we have a binary tree like below −There are two identical subtrees of size 2. We can solve this problem by using tree ... Read More

Check if a Binary Tree (not BST) has duplicate value in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Oct-2019 09:06:22

293 Views

Consider we have a binary tree, this binary tree is not a BST. We have to check whether the binary tree contains same element more than one time or not. To solve this, we will use hashing. We will traverse the given tree, for each node, we will check whether ... Read More

Check if a binary string contains all permutations of length k in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Oct-2019 09:03:53

143 Views

Suppose we have a binary string, another integer k. We have to check the string is containing all permutations of binary of k bits. Suppose a string is like “11001”, and if the K = 2, then it must have all permutations of k bit numbers. (00, 01, 10, 11), ... Read More

Check if a number from every row can be selected such that xor of the numbers is greater than zero in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Oct-2019 08:42:56

180 Views

Suppose we have one 2D array of size N x M. The task is to check if we can select a number from every row, in such a way that the XOR of those elements is non-zero or greater than 0. Suppose one matrix is like this −77710107If we perform ... Read More

Check if a line touches or intersects a circle in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Oct-2019 08:33:53

696 Views

Suppose we have a circle and another straight line. Our task is to find if the line touches the circle or intersects it, otherwise, it passes through outside. So there are three different cases like below −Here we will solve it by following steps. These are like below −Find perpendicular ... Read More

Advertisements