Arnab Chakraborty has Published 4293 Articles

Find the count of substrings in alphabetic order in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 12:37:36

150 Views

Suppose we have a string of length n. It contains only uppercase letters. We have to find the number of substrings whose character is occurring in alphabetical order. Minimum size of the substring will be 2. So if the string is like: “REFJHLMNBV”, and substring count is 2, they are ... Read More

Find the count of Strictly decreasing Subarrays in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 12:34:05

244 Views

Suppose we have an array A. And we have to find the total number of strictly decreasing subarrays of length > 1. So if A = [100, 3, 1, 15]. So decreasing sequences are [100, 3], [100, 3, 1], [15] So output will be 3. as three subarrays are found.The ... Read More

Find the count of numbers that can be formed using digits 3 and 4 only and having length at max N in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 12:31:23

109 Views

Given a number N. We have to find the count of such numbers that can be formed using digit 3 and 4. So if N = 6, then the numbers will be 3, 4, 33, 34, 43, 44.We can solve this problem if we look closely, for single digit number ... Read More

Find the closest and smaller tidy number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 12:23:29

142 Views

Suppose we have a number n, we have to find the closest and smaller tidy number of n. So a number is called tidy number, if all of its digits are sorted in non-decreasing order. So if the number is 45000, then the nearest and smaller tidy number will be ... Read More

Find the center of the circle using endpoints of diameter in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 12:20:38

196 Views

Suppose we have two endpoints of diameter of a circle. These are (x1, y1) and (x2, y2), we have to find the center of the circle. So if two points are (-9, 3) and (5, -7), then the center is at location (-2, -2).We know that the mid points of ... Read More

Find sum of a number and its maximum prime factor in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 12:17:22

181 Views

Suppose we have a positive number n, and we have to find the sum of N and its maximum prime factor. So when the number is 26, then maximum prime factor is 13, so sum will be 26 + 13 = 39.Approach is straight forward. Simply find the max prime ... Read More

Find smallest values of x and y such that ax – by = 0 in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 12:10:27

158 Views

Suppose we have two values a and b. We have to find x and y, such that ax – by = 0. So if a = 25 and b = 35, then x = 7 and y = 5.To solve this, we have to calculate the LCM of a and ... Read More

Find smallest subarray that contains all elements in same order in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 12:07:10

335 Views

Suppose we have two arrays of size m and n, The task is to find minimum length subarray in the first array, that contains all the elements if the second array. Element in second array may be present in the large array in non-contiguous but order must be same. So ... Read More

Find the Nth term of the series where each term f[i] = f[i – 1] – f[i – 2] in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 11:42:16

122 Views

Suppose we have a series called f. Each term of f, follows this rule f[i] = f[i – 1] – f[i – 2], we have to find the Nth term of this sequence. f[0] = X and f[1] = Y. If X = 2 and Y = 3, and N ... Read More

Find the last digit when factorial of A divides factorial of B in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Dec-2019 11:37:38

177 Views

If we have two integers A and B, and B >= A, we have to compute the last digit of the B! / A! When the value of A = 2 and B = 4, then result is 2, 2! = 2 and 4! = 24, so 24/2 = 12. ... Read More

Advertisements