Arnab Chakraborty has Published 4293 Articles

Find length of longest subsequence of one string which is substring of another string in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 09:40:29

2K+ Views

Suppose, we have two strings X and Y, and we have to find the length of longest subsequence of string X, which is substring in sequence Y. So if X = “ABCD” and Y = “BACDBDCD”, then output will be 3. As “ACD” is the longest sub-sequence of X, which ... Read More

Find Largest Special Prime which is less than or equal to a given number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 09:36:11

459 Views

Suppose we have a number n. We have to find the largest special prime which is less than or equal to N. The special prime is a number, which can be created by placing digits one after another, so all the resultant numbers are prime.Here we will use Sieve Of ... Read More

Find Index of 0 to be replaced with 1 to get longest continuous sequence of 1s in a binary array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 09:27:13

247 Views

Suppose, we have an array of N elements. These elements are either 0 or 1. Find the position of 0 to be replaced with 1 to get longest contiguous sequence of 1s. Suppose the array is like arr = [1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, ... Read More

Find if it is possible to reach the end through given transitions in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 09:22:29

122 Views

Suppose we have n points on x-axis and the list of allowed translation between the points. Find if it is possible to reach the end from starting point through these transactions only. So if there is a translation between points x1 and x2, then we can move from point x ... Read More

Find first non matching leaves in two binary trees in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 09:20:24

140 Views

Suppose we have two binary trees. We have to find first leaf of two trees, that does not match. If there are no non-matching leaves, then display nothing.If these are two trees, then the first non-matching leaves are 11 and 15.Here we will use the iterative preorder traversal of both ... Read More

Find Equal (or Middle) Point in a sorted array with duplicates in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 09:14:58

155 Views

Suppose we have one sorted array with n elements. The array is sorted. We have to find whether an element exists in an array from where the number of smaller element is same as the number of larger elements. If the equal point appears multiple times in the array, return ... Read More

Find cost price from given selling price and profit or loss percentage in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 07:10:28

290 Views

Consider we have the selling price, and percentage of profit or loss is given. We have to find the cost price of the product. The formula is like below −$$Cost \: Price = \frac{Sell Price * 100}{100 + Percentage \: Profit}$$$$Cost \: Price = \frac{Sell price *100}{100 + percentage\:loss}$$Example Live Demo#include ... Read More

Find all possible outcomes of a given expression in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 06:53:17

254 Views

Suppose we have an arithmetic expression without parentheses. Our task is to find all possible outcomes of that expression. Suppose the expression is like 1+2*3-4, this can be interpreted like below −1+(2*(3-4)) = 1 + (2* -1) = -1(1+2)*(3-4) = 3 * -1 = -31+((2*3)-4) = 1 + (6 - ... Read More

Find a range that covers all the elements of given N ranges in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 06:50:45

157 Views

Suppose we have a n ranges containing L and R. We have to check or find the index of 0 – based of the range which covers all the other given n – 1 ranges. If there is no such range, display -1. For example, if L = [2, 4, ... Read More

Find a range of composite numbers of given length in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Dec-2019 06:48:45

296 Views

Suppose we have a number n. We have to find the range of positive integers, where all the numbers in the range is composite, and the length of the range is n. If there are more than one range, then print any one range. The composite number is a number ... Read More

Advertisements