Arnab Chakraborty has Published 4293 Articles

Number of Subarrays with Bounded Maximum in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 09:09:25

214 Views

Suppose we have an array A of positive integers, and two positive integers L and R are also given. We have to find the number of (contiguous, non-empty) subarrays such that the value of the maximum array element in that subarray is at least L and at most R. So ... Read More

Custom Sort String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 09:07:20

544 Views

Suppose we have S and T two strings these are composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some custom order previously. We have to permute the characters of T so that they match the order that S was sorted. More specifically, ... Read More

Domino and Tromino Tiling in C++

Arnab Chakraborty

Arnab Chakraborty

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

463 Views

Suppose we have two types of shapes, Domino and Tromino. They can be rotated like below −In a tiling, every square must be covered by a tile. Here two tilings are different if and only if there are two 4-directionally adjacent cells on the board such that exactly one of ... Read More

Delete and Earn in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 09:02:50

257 Views

Suppose we have an array nums of integers, we can perform some operations on the array. Here in each operation, we pick any nums[i] and delete it to earn nums[i] amount of points. We must delete every element equal to nums[i] - 1 or nums[i] + 1. Initially the point ... Read More

Asteroid Collision in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 09:00:25

1K+ Views

Suppose we have an array asteroids of integers representing asteroids in a row. Now for each asteroid, the absolute value represents its size, and the sign represents its direction that can be positive or negative for the right and left respectively. Each asteroid moves at the same speed.We have to ... Read More

Maximum Length of Pair Chain in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 08:57:28

158 Views

Suppose in the world of Dota2, there are two parties − The Radiant and also the Dire. The Dota2 senate consists of senators coming from two parties. Now the senate wants to form a choice a few change within the Dota2 game. The voting for this alteration may be a ... Read More

Shopping Offers in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 08:53:56

281 Views

Suppose there is a store, there are some items to sell. Each item has some price. However, there are some special offers, and a special offer consists of one or more different kinds of items with a sale price. So we have the list of prices, a set of special ... Read More

Exclusive Time of Functions in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 08:48:11

306 Views

Suppose on a single threaded CPU, we execute some functions. Now each function has a unique id between 0 and N-1. We will store logs in timestamp order that describe when a function is entered or exited.Here each log is a string written this format: "{function_id}:{"start" | "end"}:{timestamp}". For example, ... Read More

Maximum XOR of Two Numbers in an Array in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 08:40:02

222 Views

Suppose we have a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. We have to find the maximum result of ai XOR aj, where 0 ≤ i, j < n. So if the input is like [3, 10, 5, 15, 2, 8], ... Read More

Random Pick Index in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 08:36:35

824 Views

Suppose we have an array of integers with possible duplicates, we have to pick the index randomly of a given target number. We can assume that the given target number must exist in the array. So if the array is like [1, 2, 3, 3, 3], then pick(3), may return ... Read More

Advertisements