Arnab Chakraborty has Published 4293 Articles

Find closest greater value for every element in array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 06:58:39

310 Views

Here we will see how to find the closest greater value for every element in an array. If an element x has next element that is larger than it, and also present in the array, then that will be the greater value of that element. If the element is not ... Read More

Find all triplets in a sorted array that forms Geometric Progression in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 06:44:40

508 Views

Suppose we have a sorted array with distinct positive integers. We have to find all triplets, that forms Geometric progression with integral common ratio. Suppose the array elements are [1, 2, 6, 10, 18, 54], The triplets are (2, 6, 18), and (6, 18, 54), these are forming geometric progression.To ... Read More

Find all the patterns of “1(0+)1” in a given string in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 06:31:21

289 Views

Suppose a string has patterns like 1(0+)1. Where (0+) indicates non-empty consecutive occurrences of 1s. We have to find all of the patterns. The patterns can overlap. The string is not necessarily a binary string. It can hold digits and lowercase characters only. Suppose the string is like 1101001, then ... Read More

Find all strings that match specific pattern in a dictionary in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 06:28:22

586 Views

Consider we have a list of strings called dictionary. We have another pattern string. Our task is to find those strings that matches the pattern. Suppose the dictionary is like [“abb”, “xyz”, “aab”, “kmm”], and pattern is “stt”, then the results will be “abb”, and “kmm”. As the pattern has ... Read More

Find all possible coordinates of parallelogram in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 06:26:57

214 Views

Find the all of the possible coordinates from the given three coordinates to make e parallelogram of a non-zero area. Suppose A, B, C are three given points we can have only three possible situations.AB, AC are sides, and BC is diagonalAB, BC are sides, and AC is diagonalBC, AC ... Read More

Find all distinct subsets of a given set in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 06:17:40

3K+ Views

Here we will see how to display all distinct subsets of a given set. So if the set is {1, 2, 3}, then the subsets will be {}, {1}, {2}, {3}, {1, 2}, {2, 3}, {1, 3}, {1, 2, 3}. The set of all subsets is called power set. The ... Read More

Find all distinct subset (or subsequence) sums of an array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 06:14:35

452 Views

Suppose we have a set of integers. Find distinct sum, that can be formed from the subset of the given sets and print them in an ascending order. The sum of array elements is small. Consider the array elements are like [1, 2, 3]. Output will be 0, 1, 2, ... Read More

Find all combinations that add upto given number using C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Nov-2019 06:06:46

490 Views

Suppose we have a positive number n. We have to find all combinations of positive numbers, that adds up to that number. Here we want only combinations, not the permutations. For the value n = 4, there will be [1, 1, 1, 1], [1, 1, 2], [2, 2], [1, 3], ... Read More

Find the value of ln(N!) using Recursion using C++.

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Oct-2019 06:39:33

192 Views

Suppose we have a number N, our task is to find ln(N!) using recursion. ln() is basically log base e. To solve this we can use this formula −$$\ln\lgroup N!\rgroup=\ln\lgroup N*\lgroup N-1\rgroup *\lgroup N-2\rgroup *\dotsm*2*1\rgroup=\ln\lgroup N\rgroup+\ln\lgroup N+1\rgroup+\dotsm+\ln\lgroup 1\rgroup$$Example Live Demo#include #include using namespace std; double factLog(int n) {    if (n ... Read More

Find the unit place digit of sum of N factorials using C++.

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Oct-2019 06:37:53

189 Views

Here we will see how to get the unit place digit of the sum of N factorials. So if N is 3, then after getting sum, we will get 1! + 2! + 3! = 9, this will be the result, for N = 4, it will be 1! + ... Read More

Advertisements