Arnab Chakraborty has Published 4293 Articles

Find the K-th minimum element from an array concatenated M times in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 11:35:33

141 Views

Consider we have an array A, and another two integers K and M. We have to find Kth minimum element after concatenating the array to itself M number of times. Suppose the array is like A = [3, 1, 2], K = 4 and M = 3, so after concatenating ... Read More

Find the Diameter or Longest chord of a Circle in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 11:25:00

130 Views

Suppose we have radius r is given. We have to find the diameter or longest chord of the circle. If the radius is 9, and diameter will be 18. This task is extremely simple, we have to find the 2*r, that is the diameter of the circle.Example Live Demo#include using namespace ... Read More

Find the common nodes in two singly linked list in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 11:23:36

441 Views

Suppose we have two singly-linked lists. We have to find the total number of common nodes in both the singly linked list. So if two lists are like [15, 16, 10, 9, 7, 17], and [15, 16, 40, 6, 9], there are three common nodes.Traverse both lists up to end ... Read More

Find the closest leaf in a Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 11:20:59

327 Views

Suppose, one binary tree is given. It has leaf nodes at different levels. Another pointer is given, that is pointing to a node. We have to find the distance to the nearest leaf node from the pointed node. Consider the tree is like below −Here leaf nodes are 2, -2 ... Read More

Find the altitude and area of an isosceles triangle in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 11:06:00

321 Views

Consider we have the side of the isosceles triangle, our task is to find the area of it and the altitude. In this type of triangle, two sides are equal. Suppose the sides of the triangle are 2, 2 and 3, then altitude is 1.32 and the area is 1.98.Altitude(h)=$$\sqrt{a^{2}-\frac{b^{2}}{2}}$$Area(A)=$\frac{1}{2}*b*h$Example Live ... Read More

Find Tangent at a given point on the curve in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 10:54:19

357 Views

Suppose we have a curve like y = x(A - x), we have to find the tangent at a given point (x, y) on that curve. Here A is an integer number, x and y are also integers.To solve this, we have the check that the given point is on ... Read More

Find sum of sum of all sub-sequences in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 10:43:11

247 Views

Consider we have an array A with n elements. We have to find the total sum of the sum of all the subsets of the array. So if the array is like A = [5, 6, 8], then it will be like −SubsetSum5566885, 6116, 8145, 8135, 6, 819Total Sum76As the ... Read More

Find sum of digits in factorial of a number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 10:40:11

531 Views

Suppose, we have a number n, our task is to find the sum of digits in then!. Consider n = 5, then n! = 120. So the result will be 3.To solve this problem, we will create a vector to store factorial digits and initialize it with 1. Then multiply ... Read More

Find reminder of array multiplication divided by n in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 10:37:48

141 Views

Suppose we have an array of n elements called A. We have to print the remainder after multiply all the numbers divided by n. Suppose A = [100, 10, 5, 25, 35, 14], and n = 11. The output is 9. So the value of 100 * 10 * 5 ... Read More

Find normal at a given point on the curve in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 10:34:57

149 Views

Suppose we have a curve like y = x(A - x), we have to find the normal at a given point (x, y) on that curve. Here A is an integer number, x and y are also integers.To solve this, we have the check that the given point is on ... Read More

Advertisements