Arnab Chakraborty has Published 4293 Articles

Reaching Points in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 10:52:50

176 Views

Suppose we have a starting points (sx, sy), and target point (tx, ty), we have to check whether a sequence of moves exists from the start point to the end point. Here move consists of taking a point (x, y) and transforming it to either (x, x+y) or (x+y, y).So ... Read More

Swim in Rising Water in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 10:50:40

317 Views

Suppose we have one N x N grid, each square grid[i][j] represents the elevation at that point (i, j). Now consider it has started raining. At time t, the depth of the water everywhere is t. We can swim from a square to another 4-directionally adjacent square when elevation of ... Read More

Cracking the Safe in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 10:48:04

377 Views

Suppose we have a box that is protected by a password. The password is a sequence of n digits where each digit can be one of the first k digits 0, 1, ..., k-1. So, when we are putting a password, the last n digits entered will automatically be matched ... Read More

Cherry Pickup in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 10:44:52

414 Views

Suppose we have one N x N grid, this is filled with cherries. Each cell has one of the possible integers as follows −0 − Indicates cell is empty, so we can pass through1 − Indicates cell contains a cherry, that we can pick up and pass through-1 − Indicates ... Read More

Find K-th Smallest Pair Distance in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 10:42:28

291 Views

Suppose we have an integer array; we have to find the kth smallest distance among all the pairs. The distance of a pair (A, B) is actually the absolute difference between A and B. So if the input is like [1, 3, 8], then all possible pairs are [1, 3], ... Read More

Range Module in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 10:40:09

298 Views

Suppose we want a Range Module. This is a module that tracks ranges of numbers. Our task is to design and implement the following interfaces in an efficient manner.addRange(left, right). This will the half-open interval [left, right), tracking every real number in that interval. Now, adding an interval that partially ... Read More

Random Pick with Blacklist in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 10:36:56

235 Views

Suppose we have a blacklist called B. This is holing unique integers from range [0, N), we have to define a function to return a uniform random integer from range [0, N) which is NOT in B. We will try to make this function more optimized by reducing random(). function ... Read More

Stickers to Spell Word in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 10:34:39

416 Views

Suppose we have N different types of stickers. In each type of sticker has a lowercase English word on it. We would like to spell out the given target string by cutting individual letters from our collection of stickers and rearranging them. We can use each sticker more than once ... Read More

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

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 10:31:54

197 Views

Suppose we have one array called nums of positive integers, we have to find three non-overlapping subarrays with maximum sum. Here each subarray will be of size k, and we want to maximize the sum of all 3*k entries.We have to find the result as a list of indices representing ... Read More

Redundant Connection II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Jun-2020 12:06:06

257 Views

Suppose we have a rooted tree. This is a directed graph such that, there is exactly one node (which is the root) for which all other nodes are descendants of this node, and every node has exactly one parent, except for the root node. Root has no parents.In the given ... Read More

Advertisements