Arnab Chakraborty has Published 3734 Articles

Find if an undirected graph contains an independent set of a given size in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 09:30:58

372 Views

Suppose we have a given undirected graph; we have to check whether it contains an independent set of size l. If there is any independent set of size l then return Yes otherwise No.We have to keep in mind that an independent set in a graph is defined as a ... Read More

Find Four points such that they form a square whose sides are parallel to x and y axes in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 09:27:11

573 Views

Suppose we have n pair of points; we have to find four points so that they can generate a square whose sides are parallel to x and y axes otherwise return "not possible" If we can find more than one square then select the one with whose area is maximum.So, ... Read More

Find four missing numbers in an array containing elements from 1 to N in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 09:21:54

251 Views

Suppose we have an array of distinct numbers where each number lies in the range [1, N], the array size is (N-4) and no single element is repeated. So, we can understand four numbers, from 1 to N, are missing in the array. We have to find these 4 missing ... Read More

Find First element in AP which is multiple of given Prime in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 09:13:48

133 Views

Suppose we have a first term (A) and common difference (d) of an AP series, and we also have a prime number P, we have to find the position of the first element in the given AP which is the a multiple of the given prime number P.So, if the ... Read More

Find element position in given monotonic sequence in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 09:11:49

312 Views

Suppose we have a number l and a monotonic increasing sequence f(m), where f(m) = am + bm [log2(m)] + cm^3 and (a = 1, 2, 3, …), (b = 1, 2, 3, …), (c = 0, 1, 2, 3, …)Here [log2(m)] is the log to the base 2 and ... Read More

Find Duplicates of array using bit array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 09:09:37

232 Views

Suppose we have an array of n different numbers; n can be 32, 000 at max. The array may have duplicate entries and we do not know what is the value of n. Now if we have only 4-Kilobytes of memory, how would display all duplicates in the array?So, if ... Read More

Find distinct elements common to all rows of a matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 09:07:56

352 Views

Suppose we have a square matrix of order m x m; we have to find all the distinct elements common to all rows of the given matrix.So, if the input is like13215417153243615215412152643221942215then the output will be [2, 4, 15]To solve this, we will follow these steps −Define a function sortRows() ... Read More

Find d to maximize the number of zeros in array c[] created as c[i] = d*a[i] + b[i] in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 09:04:02

276 Views

Suppose we have two arrays A and B of n integers, now consider an array C, where the i-th number will be d*A[i] + B[i] and here d is any arbitrary real number. We have to find d such that array C has maximum number of zeros. Also return the ... Read More

Find combined mean and variance of two series in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Aug-2020 09:01:19

898 Views

Suppose we have two different series A1 and A2 of size b and a respectively. We have to find the mean and variance of combined series.So, if the input is like A1 = [24, 46, 35, 79, 13, 77, 35] and A2 = [66, 68, 35, 24, 46], then the ... Read More

Find the minimum sum of distance to A and B from any integer point in a ring of size N in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Aug-2020 08:40:14

180 Views

Suppose we have a ring, which is made of few numbers from 1 to N. We also have tow numbers A and B. Now, we can stand at any place (say x) and perform the count operation with respect of the total sum of the distance (say Z = distance ... Read More

Advertisements