Arnab Chakraborty has Published 4293 Articles

Two Sum BSTs in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 06:45:28

189 Views

Suppose we have two binary search trees, we have to return True iff there is a node in the first tree and a node in the second tree and sum of these nodes is a given integer target. So if the tree is like −and target is 5, then the ... Read More

Maximum Subarray Sum with One Deletion in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 06:36:31

355 Views

Suppose we have an array of integers; we have to find the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, we can say that we want to choose a subarray and optionally delete one element from it so that there is ... Read More

Can Make Palindrome from Substring in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 06:32:37

185 Views

Suppose we have a string s, we have to make queries on substrings of s. For each query queries[i], there are three parts [left, right, k], we may rearrange the substring s[left], ..., s[right], and then choose up to k of them to replace with any lowercase English letter. If ... Read More

Minimum Cost to Connect Sticks in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 06:27:42

390 Views

Suppose we have some sticks with positive integer lengths. We can connect any two sticks of lengths X and Y into one stick by paying a cost of X + Y. This will be performed until there is one stick remaining. We have to find the minimum cost of connecting ... Read More

Design File System in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 06:22:05

2K+ Views

Suppose we have to design a file system which provides these two functions −createPath(path, value) − This creates a new path and associates a value to it if possible and returns True. It returns False if the path already exists or its parent path doesn't exist.get(path) − This finds the ... Read More

Maximum Level Sum of a Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 06:14:36

278 Views

Suppose we have the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. We have to return the smallest level X such that the sum of all the values of nodes at level X is maximal. So ... Read More

Construct Binary Tree from Preorder and Postorder Traversal in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 06:14:19

483 Views

Suppose we have two traversal sequences Preorder and Postorder, we have to generate the binary tree from these two sequences. So if the sequences are [1, 2, 4, 5, 3, 6, 7], [4, 5, 2, 6, 7, 3, 1], then the output will beTo solve this, we will follow these ... Read More

Decoded String at Index in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 06:09:03

202 Views

Suppose one encoded string S is given. We have to find and write the decoded string to a tape, here the encoded string is read one character at a time and the following steps are performed −If the character read is a letter, that letter is simply written onto the ... Read More

Number of Dice Rolls With Target Sum in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 06:06:31

858 Views

Suppose we have d dice, and each die has f number of faces numbered 1, 2, ..., f. We have to find the number of possible ways (out of fd total ways) modulo 10^9 + 7 to roll the dice so the sum of the face up numbers equal to ... Read More

Most Profit Assigning Work in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 30-Apr-2020 06:04:56

359 Views

Suppose we have jobs difficulty[i] and this array indicates the difficulty of the ith job, and profit[i] is the profit of the ith job. Now consider we have some workers. worker[i] is the ability of the ith worker, this means that this worker can only complete a job with difficulty ... Read More

Advertisements