Arnab Chakraborty has Published 4293 Articles

Merge k sorted arrays of different sizes in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Aug-2020 12:12:12

610 Views

Suppose we have different k sorted arrays. We have to merge these arrays and display the sorted result.So, if the input is like k = 3 and arrays are {2, 4}, {3, 5, 7}, {1, 10, 11, 12} , then the output will be 1 2 3 4 5 7 ... Read More

Find the starting indices of the substrings in string (S) which is made by concatenating all words from a list(L) in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Aug-2020 12:11:48

199 Views

Suppose we have a string, s, and we have another list with few words, these words are of same length. We have to find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters.So if the input ... Read More

Maximum Consecutive Increasing Path Length in Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Aug-2020 12:09:46

254 Views

Suppose we have a binary tree; we have to calculate the length of the longest path which consists of nodes with consecutive values in increasing order. Every node will be treated as a path of length 1.So, if the input is likethen the output will be 3 as (11, 12, ... Read More

Find the smallest window in a string containing all characters of another string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Aug-2020 12:07:33

475 Views

Suppose we have two strings s1 and s2, we have to find the smallest substring in s1 such that all characters of s2 will be used efficiently.So, if the input is like s1 = "I am a student", s2 = "mdn", then the output will be "m a studen"To solve ... Read More

Unique element in an array where all elements occur k times except one in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Aug-2020 12:05:14

429 Views

we have an array A. A has all elements occurring m times, but one element occurs only once. We have to find that unique element.So, if the input is like A = [6, 2, 7, 2, 2, 6, 6], m = 3, then the output will be 7.To solve this, ... Read More

Find the smallest positive integer value that cannot be represented as sum of any subset of a given array in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Aug-2020 12:04:59

610 Views

Suppose we have a sorted array of positive numbers, this array is sorted in ascending order, er have to find the smallest positive value that cannot be represented as sum of elements of any subset of given set. We have to solve this problem in O(n) time.So, if the input ... Read More

Find the shortest distance between any pair of two different good nodes in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Aug-2020 12:03:08

468 Views

Suppose we have a given weighted undirected graph with N different nodes and M edges, some of the nodes are good nodes. We have to find the shortest distance between any pair of two different good nodes. In the given diagram the yellow in the following graph are considered to ... Read More

Find the probability of reaching all points after N moves from point N in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Aug-2020 11:58:22

135 Views

Suppose we have a number N this represents the initial position of the person on the number line. We also have L which is the probability of the person of going left. We have to find the the probability of reaching all points on the number line after completing N ... Read More

Succinct Encoding of Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Aug-2020 11:11:38

383 Views

Suppose we have a binary tree. As we know the succinct encoding of Binary Tree performs close to lowest possible space. The n’th Catalan number is designated by the number of structurally different binary trees with n different nodes. If the n is large, this is about 4n; thus, we ... Read More

Find the probability of a state at a given time in a Markov chain - Set 1 in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 27-Aug-2020 06:36:52

372 Views

Suppose we have a Markov chain graph g; we have the find the probability to reach the state F at time T if we start from state S when time t = 0. As we know a Markov chain is a random process consisting of various states and the probabilities ... Read More

Advertisements