Arnab Chakraborty has Published 4293 Articles

Program to count number of permutations where sum of adjacent pairs are perfect square in Python

Arnab Chakraborty

Arnab Chakraborty

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

228 Views

Suppose we have a list of numbers called nums. We have to find the number of permutations of nums such that sum of every pair of adjacent values is a perfect square. Two permutations A and B are unique when there is some index i where A[i] is not same ... Read More

Program to check whether final string can be formed using other two strings or not in Python

Arnab Chakraborty

Arnab Chakraborty

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

152 Views

Suppose we have two strings s, t, and another string r we have to check whether there is any way to get r by merging characters in order from s and t.So, if the input is like s = "xyz" t = "mno" r = "xymnoz", then the output will ... Read More

Program to count number of flipping required to make all x before y in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:37:17

183 Views

Suppose we have a lowercase string s with letters x and y. Now consider an operation in which we change a single x to y or vice versa. We have to find the minimum number of times we need to perform that operation to set all x's come before all ... Read More

Program to check person can reach top-left or bottomright cell avoiding fire or not in Python

Arnab Chakraborty

Arnab Chakraborty

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

131 Views

Suppose we have a 2D matrix with few different values like below −0 for empty cell1 for a person2 for fire3 for a wallNow assume there is only one person and in each turn the fire expands in all four directions (up, down, left and right) but fire cannot expand ... Read More

Program to count number of walls required to partition top-left and bottom-right cells in Python

Arnab Chakraborty

Arnab Chakraborty

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

221 Views

Suppose we have a 2d binary matrix where 0 represents empty cell and 1 represents a wall. We have to find the minimum number cells that need to become walls so that there will be no path between top−left cell and bottom-right cell. We cannot put walls on the top−left ... Read More

Program to find number of unique subsequences same as target in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 06:03:39

152 Views

Suppose we have two lowercase strings s and t, we have to find the number of subsequences of s that are equal to t. If the answer is very large then return result by 10^9 + 7.So, if the input is like s = "abbd" t = "bd", then the ... Read More

Program to count number of distinct characters of every substring of a string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 06:01:45

308 Views

Suppose we have a lowercase string s, we have to find the sum of the count of characters that are distinct in every substring of s. If the answer is very large then return result mod 10^9+7.So, if the input is like s = "xxy", then the output will be ... Read More

Program to find number of operations needed to convert list into non-increasing list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 06:00:33

153 Views

Suppose we have a list of numbers called nums. Now let us consider an operation where we take two consecutive values and merge it into one value by taking their sum. We have to find the minimum number of operations required so that the list turns into non−increasing.So, if the ... Read More

Program to count number of configurations are there to fill area with dominos and trominos in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 05:58:00

105 Views

Suppose we have two shapes, Domino and Tromino. Dominos are 2 x 1 shape and Trominos are ‘L’ like shape. They can be rotated like below −If we have a number n, we have to find number of configurations to fill a 2 x n board with these two types ... Read More

Program to count number of trailing zeros of minimum number x which is divisible by all values from 1 to k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 05:56:38

143 Views

Suppose we have a number k, now consider the smallest positive integer value x where all values from 1 to k divide evenly. In other words, consider the smallest value x where x is divisible by all numbers from 1 through k. We have to find the number of trailing ... Read More

Advertisements