Arnab Chakraborty has Published 4293 Articles

Binary Tree Longest Consecutive Sequence II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 16-Nov-2020 14:08:24

296 Views

Suppose we have a binary tree; we have to find the length of the Longest Consecutive Path in that Binary Tree. Here the path can be either increasing or decreasing. So as an example [1, 2, 3, 4] and [4, 3, 2, 1] are both considered as a valid path, ... Read More

Split Array with Equal Sum in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 16-Nov-2020 14:05:16

864 Views

Suppose we have an array with n integers, we have to find if there are triplets (i, j, k) which follows these conditions −0 < i, i + 1 < j, j + 1 < k < n - 1Sum of subarrays (0, i - 1), (i + 1, j ... Read More

Boundary of Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 16-Nov-2020 14:02:36

224 Views

Suppose we have a binary tree, we have to find the values of its boundary in anti-clockwise direction starting from root. Here boundary includes left boundary, leaves, and the right boundary in order without duplicate nodes.The left boundary is the path from root to the left-most node.The Right boundary is ... Read More

Output Contest Matches in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 16-Nov-2020 13:58:18

207 Views

Suppose we have n teams and we always arrange the rather strong team to play with the rather weak team, like make the rank 1 team play with the team with rank n, this strategy is to make the contest more interesting. Now we have to find their final contest ... Read More

Construct Binary Tree from String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 16-Nov-2020 13:56:15

2K+ Views

Suppose we have a string consisting of parenthesis and integers. We have to construct a binary tree from that string. The whole input represents a binary tree. It holds an integer that followed by zero, one or two pairs of parentheses. The integer represents the root's value and a pair ... Read More

Lonely Pixel II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 16-Nov-2020 13:52:40

170 Views

Suppose we have a picture consisting of black and white pixels, we have to find the number of black pixels, which are present at row R and column C. That is aligned with all the following rules −R and C will contain exactly N black pixelsFor all rows, that have ... Read More

Rotting Oranges in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 16-Nov-2020 13:48:11

239 Views

Suppose we have a grid, here in each cell can have one of three values −value 0 for an empty cell;value 1 for a fresh orange;value 2 for a rotten orange.In every minute, any fresh orange that is adjacent to a rotten orange becomes rotten.We have to find the minimum ... Read More

Cousins in Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 16-Nov-2020 13:32:53

539 Views

Suppose we have a binary tree, the root node is present at depth 0, and children of each depth k node are at depth k+1.Here two nodes of a binary tree are called cousins if they have the same depth, but have different parents.All values of the tree will be ... Read More

Moving Stones Until Consecutive II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 13-Nov-2020 12:05:38

232 Views

Suppose we are considering an infinite number line, here the position of the i−th stone is given by array stones and stones[i] is indicating ith stone position. A stone is an endpoint stone if it has the smallest or largest position. Now in each turn, we pick up an endpoint ... Read More

Maximum Sum of Two Non-Overlapping Subarrays in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 13-Nov-2020 11:45:44

240 Views

Suppose we have an array A of integers; we have to find the maximum sum of elements in two non−overlapping subarrays. The lengths of these subarrays are L and M.So more precisely we can say that, we have to find the largest V for whichV = (A[i] + A[i+1] + ... Read More

Advertisements