Arnab Chakraborty has Published 4452 Articles

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

75 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

165 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

67 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

187 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

82 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

67 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

90 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

Program to find top view of a binary tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 05:55:52

275 Views

Suppose we have a binary tree, we have to find the top view of the tree, they will be sorted left−to−right.So, if the input is like image, then the output will be [3, 5, 8, 6, 9], as 3 is above 2 and 5 is above 7 so they are ... Read More

Program to find number of minimum steps required to meet all person at any cell in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 05:53:06

95 Views

Suppose we have a 2D matrix where these values are present: 0 represents an empty cell. 1 represents a wall. 2 represents a person. Now a person can walk any of the four direction of up, down, left, right otherwise stay in one time unit. We have to find a ... Read More

Program to find minimum number of steps required to catch the opponent in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 25-Dec-2020 05:49:05

129 Views

Suppose we have a list of tree edges in the form [u, v], this indicates there is an undirected edge between u and v. And we also have two values x and y. If we are at node x, and our opponent is at node y. In the first round, ... Read More

Advertisements