Arnab Chakraborty has Published 4452 Articles

Longest Line of Consecutive One in Matrix in C++

Arnab Chakraborty

Arnab Chakraborty

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

291 Views

Suppose we have one binary matrix M, we have to find the longest line of consecutive one in that matrix. The line could be horizontal, vertical, diagonal or anti-diagonal.So, if the input is like011001100001then the output will be 3To solve this, we will follow these steps −ret := 0n := ... Read More

Split Concatenated Strings in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 16-Nov-2020 14:11:41

411 Views

Suppose we have a list of strings, we can concatenate these strings together into a loop, where for each string we can choose to reverse it or not. Among all of the possible loops, we need to find the lexicographically largest string after cutting the loop, which will make the ... Read More

Binary Tree Longest Consecutive Sequence II in C++

Arnab Chakraborty

Arnab Chakraborty

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

221 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

741 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

136 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

124 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

1K+ 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

58 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

157 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

435 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

Advertisements