Arnab Chakraborty has Published 4293 Articles

Find a number which give minimum sum when XOR with every number of array of integer in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 08:25:24

274 Views

ConceptWith respect of given array Arr[] of non-negative integers, the task is to determine an integer X such that (Arr[0] XOR X) + (Arr[1] XOR X) + … + Arr[n – 1] XOR X is minimum possible.Input Arr[] = {3, 4, 5, 6, 7}Output X = 7, Sum = 10ApproachSo we will ... Read More

fillpoly() function in C

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 08:18:25

679 Views

ConceptNow the header file graphics.h contains fillpoly() function which is implemented to draw and fill a polygon such as triangle, rectangle, pentagon, hexagon etc. So this function require same arguments as drawpoly().Syntaxvoid fillpoly( int number, int *polypoints );In this case, number indicates (n + 1) number of points where, n ... Read More

Check if a number is Primorial Prime or not in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 08:06:23

374 Views

ConceptWith respect of given positive number n, the task is to verify if n is a primorial prime number or not. We have to print ‘YES’ if n is a primorial prime number otherwise print ‘NO.Primorial Prime − With respect of Mathematics, a Primorial prime is defined as a prime ... Read More

Check if a number is an Achilles number or not in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 08:03:56

212 Views

ConceptWith respect of given positive integer n, the task is to verify if n is an Achilles number or not. We have to print 'YES' if N is treated as an Achilles number else print 'NO'.Achilles number: With respect of Mathematics, an Achilles number is defined as a number that ... Read More

Check if a number is a Trojan Numbers in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:59:54

141 Views

ConceptWith respect of given number n, the task is to verify whether n is a Trojan Number or not. Trojan Number is defined as a number that is a strong number without a perfect power. We can say that a number n is treated as a strong number if, for ... Read More

Check if a king can move a valid move or not when N nights are there in a modified chessboard in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:54:29

402 Views

ConceptWith respect of given infinite chessboard with the same rules as that of chess and given N knights coordinates on the infinite chessboard (-10^9 {3, 4}Output NoThe king can be able to make valid moves.MethodHere, the knight’s move is unusual among chess pieces. Its movement is towards a square that ... Read More

Check if a key is present in every segment of size k in an array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:53:05

453 Views

ConceptWith respect of a given array arr1[] with size of array N, one another key X and a segment size K, the task is to determine that the key X present in every segment of size K in arr1[].Input arr1[] = { 4, 6, 3, 5, 10, 4, 2, 8, 4, ... Read More

Check if a given string is a valid number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:51:03

522 Views

ConceptIt should be validated if a given string is numeric.Input − str = "12.5"Output − trueInput − str = "def"Output − falseInput − str = "2e5"Output − trueInput − 10e4.4Output − falseMethodWe have to handle the following cases in the code.We have to ignore the leading and trailing white spaces.We ... Read More

Check if a given Binary Tree is Heap in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:43:58

377 Views

ConceptWith respect of a given binary tree, we need to verify whether it has heap property or not, Binary tree need to satisfy the following two conditions for being a heap –Binary tree should be a complete tree (i.e. all levels except last should be full).Binary tree's every node’s value ... Read More

Check if a given Binary Tree is height balanced like a Red-Black Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 07:40:25

240 Views

ConceptWith respect of a Red-Black Tree, the largest height of a node is at most double the minimum height.For a given Binary Search Tree, we need to verify for following property.With respect of every node, length of the longest leaf to node path has not more than double the nodes ... Read More

Advertisements