Arnab Chakraborty has Published 4293 Articles

Encode N-ary Tree to Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 08:57:15

588 Views

Suppose we have a N-ary tree. We have to encode that tree into one binary. We also have to make deserializer to deserialize the binary tree to N-ary tree.So, if the input is likethen the output will beTo solve this, we will follow these steps −Define a function encode(), this ... Read More

Serialize and Deserialize N-ary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 08:53:52

409 Views

Suppose we have one N-ary tree and we have to serialize and deserialize them. As we know that the serialization is the process of converting a data structure or object into a sequence of bits so we can store them in a file or memory buffer, and that can be ... Read More

Word Squares in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 08:49:06

325 Views

Suppose we have a set of words (all are unique), we have to find all word squares and we can build from them. Here a sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 ≤ k < maximum ... Read More

Perfect Rectangle in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 08:46:27

251 Views

Suppose we have N axis-aligned rectangles, we have to check whether they all together form an exact cover of a rectangular region or not. Here each rectangle is represented as a bottom-left point and a top-right point. So a unit square is represented as [1, 1, 2, 2]. (bottom-left point ... Read More

Minimum Unique Word Abbreviation in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 08:45:17

309 Views

Suppose we have a string such as "word" and that contains the following abbreviations: ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]. We also have a target string and a set of strings in a dictionary, we have to find an abbreviation ... Read More

Rearrange String k Distance Apart in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 08:36:50

584 Views

Suppose we have a non-empty string s and an integer k; we have to rearrange the string such that the same characters are at least distance k from each other. Given strings are in lowercase letters. If there is no way to rearrange the strings, then we will an empty ... Read More

Longest Substring with At Most K Distinct Characters in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 08:27:55

1K+ Views

Suppose we have a string; we have to calculate the length of the longest substring T that contains at most k distinct characters.So, if the input is like s = "eceba", k = 2, then the output will be 3 as T is "ece" which its length is 3.To solve ... Read More

Range Sum Query 2D - Mutable in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 08:17:37

484 Views

Suppose we have a 2D matrix called matrix, we have to calculate the sum of the elements inside the rectangle defined by its upper left corner and lower right corner.So, if the input is like3014256321120154101710305So will be methods to find sum, update value, if we call them likesumRegion(2, 1, 4, ... Read More

Smallest Rectangle Enclosing Black Pixels in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 08:12:40

413 Views

Suppose we have an image and that image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. Here the black pixels are connected, so there is only one black region. Pixels are connected horizontally and vertically. If we have a location ... Read More

Serialize and Deserialize Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 08:09:58

919 Views

Suppose we have one binary tree and we have to serialize and deserialize them. As we know that the serialization is the process of converting a data structure or object into a sequence of bits so we can store them in a file or memory buffer, and that can be ... Read More

Advertisements