Arnab Chakraborty has Published 4293 Articles

Distinct Subsequences II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jun-2020 09:16:08

156 Views

Suppose we have a string S, we have to count the number of distinct subsequences of S. The result can be large, so we will return the answer modulo 10^9 + 7.So, if the input is like "bab", then the output will be 6, as there are 6 different sequences, ... Read More

Three Equal Parts in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jun-2020 09:13:31

187 Views

Suppose we have one array A of 0s and 1s, we have to divide the array into 3 non-empty parts such that all of these parts represent the same binary value. If that is possible, return any [i, j] with i+1 < j, such that −A[0], A[1], ..., A[i] is ... Read More

Number of Music Playlists in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jun-2020 09:07:53

511 Views

Suppose we have a music player, that contains N different songs and we want to listen to L songs during our trip. So we have to make a playlist so that it meets these conditions −Every song is played at least onceA song can only be played again only if ... Read More

Super Palindromes in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jun-2020 09:03:27

525 Views

Suppose we have a positive integer N, that is said to be a superpalindrome if it is a palindrome, and it is also the square of a palindrome. Now consider we have two positive integers L and R we have to find the number of superpalindromes in the inclusive range ... Read More

Valid Permutations for DI Sequence in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jun-2020 09:00:57

771 Views

Suppose we have a string S. This is a string of characters from the set {'D', 'I'}. (D means "decreasing" and I means "increasing")Now consider a valid permutation is a permutation P[0], P[1], ..., P[n] of integers {0 to n}, such that for all i, it meets these rules:If S[i] ... Read More

Numbers At Most N Given Digit Set in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jun-2020 08:58:56

182 Views

Suppose we have one sorted set of digits D, a non-empty subset of {'1', '2', '3', '4', '5', '6', '7', '8', '9'} except 0. Now, we will write some numbers using these digits, using each digit as many times as we want. So, if D = {'2', '3', '7'}, we ... Read More

Orderly Queue in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jun-2020 08:56:21

229 Views

Suppose there is a string S. All letters in S are in lowercase. Then, we may make any number of moves.Here, in each move, we choose one of the first K letters, and remove it, and place it at the end of the string. We have to find the lexicographically ... Read More

Maximum Frequency Stack in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jun-2020 08:53:44

419 Views

Suppose we want to implement one stack called FreqStack, Our FreqStack has two functions −push(x), This will push an integer 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 same frequency, then the element closest ... Read More

Sum of Subsequence Widths in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jun-2020 08:50:02

184 Views

Suppose we have an array A of integers, consider all non-empty subsequences of A. For any sequence S, consider the width of S be the difference between the maximum and minimum element of S. We have to find the sum of the widths of all subsequences of A. The answer ... Read More

Super Egg Drop in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Jun-2020 08:47:29

476 Views

Suppose we have given K eggs, and we have a building with N floors from 1 to N. Now each egg is identical in function, and if an egg breaks, we cannot drop it again.There exists a floor F with between 0 and N such that any egg dropped at ... Read More

Advertisements