Arnab Chakraborty has Published 4293 Articles

Program to find largest average of sublist whose size at least k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:59:53

308 Views

Suppose we have a list of numbers called nums and another value k, we have to find the largest average value of any sublist of the list whose length is at least k.So, if the input is like nums = [2, 10, -50, 4, 6, 6] k = 3, then ... Read More

Program to find kth lexicographic sequence from 1 to n of size k Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:57:54

206 Views

Suppose we have two values n and k. Now consider a list of numbers in range 1 through n [1, 2, ..., n] and generating every permutation of this list in lexicographic sequence. For example, if n = 4 we have [1234, 1243, 1324, 1342, 1423, 1432, 2134, 2143, 2314, ... Read More

Program to construct Frequency Stack in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:56:34

170 Views

Suppose we want to construct one stack called FrequencyStack, Our FrequencyStack has two functions −append(x), This will append or push a value x onto the stack.pop(), This will remove and returns the most frequent element in the stack. If there are more than one elements with the same frequency, then ... Read More

Program to find final amount that should be paid to employees based on their performance in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:54:40

220 Views

Suppose we have two lists of numbers of same length called performance and costs. And we also have another number k. These indicates that each worker i performs at performance[i] level and it takes costs at least costs[i]. We have to find the minimum cost to hire k employees given ... Read More

Program to count number of unique subsequences of a string in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:54:01

660 Views

Suppose we have a string s, we have to find the number of non-empty unique subsequences of s. If the answer is very large then mod the result by 10^9 + 7.So, if the input is like s = "xxy", then the output will be 5, as there are five ... Read More

Program to find number of distinct island shapes from a given matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:52:44

306 Views

Suppose we have a 2d binary matrix, we have to find the number of distinct islands in the given matrix. Here 1 represents land and 0 represents water, so an island is a set of 1s that are close and whose perimeter is surrounded by water. Here two islands are ... Read More

Program to count number of ways we can make a list of values by splitting numeric string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:50:41

112 Views

Suppose we have a strings s. The s is containing digits from 0 - 9 and we also have another number k. We have to find the number of different ways that s can be represented as a list of numbers from [1, k]. If the answer is very large ... Read More

Program to find number of coins we can pick from topleft to bottom-right cell and return in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:48:38

167 Views

Suppose we have a 2D matrix with 3 possible values −0 for an empty cell.1 for a coin.−1 for a wall.We have to find the maximum number of coins we can take by starting from the top−left cell and reaching the bottom−right cell by moving only right or down direction. ... Read More

Program to check person 1 can win the candy game by taking maximum score or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:44:27

328 Views

Suppose two players are playing a game. Where several candies placed on a line, and person 1 is given a list of numbers called nums that is representing the point value of each candy. On each person's turn, they can pick 1, 2, or 3 candies from the front of ... Read More

Program to check whether first player can take more candies than other or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:43:07

169 Views

Suppose we have a list of numbers called candies and two persons are racing to collect the most number of candies. Here the race is turn based, person 1 is starting first, and in each turn he can pick up candies from the front or from the back. We have ... Read More

Advertisements