Arnab Chakraborty has Published 4293 Articles

Find out the minimum number of coins required to pay total amount in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 12:46:38

305 Views

Suppose we have a number N, and unlimited number of coins worth 1, 10 and 25 currency coins. Find minimum number of coins we need to use to pay exactly amount N. Suppose N is 14, then number of coins will be 5, as one 10 value coin and four ... Read More

Find the minimum number of steps to reach M from N in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 12:45:29

859 Views

Suppose we have two integers N and M. We have to find minimum number of steps to reach M from N, by performing given operations −Multiply the number x by 2, so x will be 2*xSubtract one from the number x, so the number will be x – 1If N ... Read More

Find number of diagonals in n sided convex polygon in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 12:44:23

404 Views

Suppose we have a number n, and we have to find the number of diagonals for n sided convex polygon. So if the n = 5, then diagonals count will be 5.As this is n-sided convex polygon, from each vertex we can draw n – 3 diagonals leaving two sided ... Read More

Find the minimum distance between two numbers in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 12:43:26

1K+ Views

Suppose we have one unsorted array A, and two numbers x and y. We have to find the minimum distance between x and y in A. The array can also contain duplicate elements. So if the array is A = [2, 5, 3, 5, 4, 4, 2, 3], x = ... Read More

Find the longest sub-array having exactly k odd numbers in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 12:41:44

122 Views

Suppose we have one array with n elements. The problem is to find longest sub-array which has exactly k odd numbers. So if A = [2, 3, 4, 11, 4, 12, 7], and k = 1, then output will be 4, sub-array is [4, 11, 4, 12]We can solve this ... Read More

Find number of cavities in a matrix in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 12:39:31

137 Views

Consider one matrix is given. We have to find the number of cavities in the matrix. One element is denoted as cavity when all other elements surrounding it is greater than the element. So if the matrix is like −456715456So the output is 1.We simply check the surrounding elements and ... Read More

Find the longest path in a matrix with given constraints in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 12:38:25

528 Views

Suppose we have one square matrix of order n. It has all distinct elements. So we have to find the maximum length path, such that all cells along the path are in increasing order with a difference of 1. From one cell we can move to four directions. Left, Right, ... Read More

Find the longest common prefix between two strings after performing swaps on second string in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 12:35:42

322 Views

Suppose we have two strings str1 and str2. Find the longest common prefix between them after performing zero or more operation on the second string. In each operation, we can swap any two letters. So if str1 = “HERE”, str2 = “THERE”, then output will be 4. The second string ... Read More

Find number from given list for which value of the function is closest to A in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 12:33:32

144 Views

Suppose we have a function F(n) such that F(n) = P – (0.006*n), where P is also given. Given a list of integers and a number A. The task is to find the number from given list, for which the value of the function is nearer to A. So if ... Read More

Find nth number that contains the digit k or divisible by k in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 12:30:28

594 Views

Given two positive integers n and k, and we have to find the nth number that contains the digit k or divisible by k. The k will be in range [2 to 9]. So if n and k are 15 and 3 respectively, then output is 33. As the numbers ... Read More

Advertisements