Arnab Chakraborty has Published 4293 Articles

Replace the Substring for Balanced String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 11:27:44

480 Views

Suppose we have a string containing only 4 kinds of characters 'Q', 'W', 'E' and 'R'. A string will be balanced if each of its characters appears n/4 times where n is the length of the string. Find the minimum length of the substring that can be replaced with any ... Read More

Search Suggestions System in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 11:12:02

388 Views

Suppose we have an array of strings products and a string called searchWord. We want to design a module that suggests at most three product names from products list after each character of searchWord is typed. The suggested products should have common prefix with the searchWord. When there are more ... Read More

Find Elements in a Contaminated Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 11:10:42

205 Views

Suppose we have a binary tree. The rules of that tree is as follows −root.val == 0If treeNode.val is x and treeNode.left is not null, then treeNode.left.val = 2 * x + 1If treeNode.val is x and treeNode.right is not null, then treeNode.right.val = 2 * x + 2Now as ... Read More

Minimum Remove to Make Valid Parentheses in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 11:07:25

445 Views

Suppose we have a string s of '(' , ')' and lowercase English characters. We have to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parenthese string is valid and return any valid string. A parentheses string is valid when ... Read More

Number of Closed Islands in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 11:05:44

292 Views

Suppose we have a 2D grid consists of 0s (as land) and 1s (as water). An island is a maximal 4- directionally connected group of 0s. A closed island is an island totally surrounded by 1s. We have to find the number of closed islands. So if the grid is ... Read More

Maximum Nesting Depth of Two Valid Parentheses Strings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 11:03:09

311 Views

Suppose we have a string, that string is a valid parentheses string (denoted VPS) if and only if it consists of "(" and ")" characters only, and it satisfies these properties −It is the empty string, orIt can be written as AB, where A and B are VPS's, orIt can ... Read More

Shortest Path in Binary Matrix in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 11:01:56

833 Views

Suppose we have an N by N square grid, there each cell is either empty (0) or blocked (1). A clear path from top-left to bottom-right has length k if and only if it is composed of cells C_1, C_2, ..., C_k such that −Adjacent cells C_i and C_{i+1} are ... Read More

Grumpy Bookstore Owner in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 11:00:29

238 Views

Suppose a bookstore owner has a store open for number of customers list entries minutes. In every minute, some number of customers (customers[i]) enter the store, after that all those customers leave after the end of that minute. On some minutes, the owner is grumpy. Now if the owner is ... Read More

Maximum Difference Between Node and Ancestor in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 10:51:08

193 Views

Suppose we have the root of a binary tree, we have to find the maximum value V for which there exists different nodes A and B where V = |value of A – value of B| and A is an ancestor of B. So if the tree is like −Then ... Read More

Capacity To Ship Packages Within D Days in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 10:46:47

337 Views

Suppose there is a conveyor belt has packages that will be shipped from one port to another within D days. Here the i-th package on the conveyor belt has a weight of weights[i]. Each day, we will load the ship with packages on the belt. We will not load more ... Read More

Advertisements