Arnab Chakraborty has Published 4293 Articles

IPO in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Jun-2020 11:30:11

441 Views

Suppose one company A wants to start its IPO soon. In order to sell a good price of its shares to B, A would like to work on some projects to increase its capital before the IPO. A has limited resources, it can only finish at most k distinct projects ... Read More

Reverse Pairs in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Jun-2020 11:29:05

916 Views

Suppose we have an array, in this array we will say one pair (A[i] and A[j]) as important reverse pairs if this satisfies the following condition −if i < j and A[i] > 2* nums[j]We have to find the number of important reverse pairs. So if the input is like ... Read More

Zuma Game in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Jun-2020 11:26:46

873 Views

Let us consider about the Zuma Game. Suppose we have a row of balls on the table, these balls are colored as red(R), yellow(Y), blue(B), green(G), and white(W). We also have several balls with us.Now, each time, we may choose a ball from our side, and insert it into the ... Read More

Smallest Good Base in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Jun-2020 11:23:44

364 Views

Suppose we have an integer n, we call k >= 2 as a good base of n, when all digits of n base k are 1. So if the number n is given as string, we have to return smallest good base of n as string. So if the number ... Read More

Sliding Window Median in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Jun-2020 11:21:03

1K+ Views

Suppose we have a list of numbers, and we have one window size k, we have to find the list of medians using sliding window manner. So, if the distribution is like below −Window PositionMedian13-1-35368113-1-35368-113-1-35368-113-1-35368313-1-35368513-1-353686Here we have considered the k is 3, and the result will be [1, -1, -1, ... Read More

Largest Palindrome Product in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Jun-2020 11:10:12

162 Views

Suppose we have input n, we have to find the largest palindrome that can be made using multiplication of two n digit numbers. As the numbers are very large, we can perform mod using 1337. So if the input is say 2, then the answer will be 987, 987 = ... Read More

Concatenated Words in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Jun-2020 11:07:49

212 Views

Suppose we have a list of words. These words are distinct. We have to devise an algorithm that will find all concatenated words in the give list of words. A concatenated word is actually a string that is comprised entirely of at least two shorter words in the given array.So ... Read More

Poor Pigs in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Jun-2020 11:03:44

217 Views

Suppose there are 1000 buckets, one of them is poisonous, others are filled with water. They all look similar. If a pig drinks the poison it will die within 15 minutes. What will be the minimum amount of pigs that we need to find out the poisonous bucket within one ... Read More

Arithmetic Slices II - Subsequence in C++

Arnab Chakraborty

Arnab Chakraborty

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

255 Views

Suppose we have an array A, where N numbers are present. A subsequence slice of that array is any sequence of integers like (K0, K1, K2, … Kn) such that 0 = 2. So we have to return the number of arithmetic slices.So if the input is like [2, 4, ... Read More

K-th Smallest in Lexicographical Order in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 01-Jun-2020 10:55:27

795 Views

Suppose we have two values n and k. We have to find the lexicographically kth smallest integer in the range of 1 to n. So if the input is like n = 14 and k = 3, then the output will be 11, as the sequence will be [1, 10, ... Read More

Advertisements