Arnab Chakraborty has Published 4293 Articles

Program to find maximum profit after cutting rods and selling same length rods in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 12:11:39

486 Views

Suppose we have a list of rod lengths called rodLen. We also have another two integers called profit and cost, represents profit per length and cost per cut. We can make gain profit per unit length of a rod but we can only sell rods that are all of the ... Read More

Program to find maximum length of k ribbons of same length in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 12:08:11

1K+ Views

Suppose we have a list of positive numbers, representing ribbons length and also have one value k. We can cut the ribbons as many times as we want, we have to find the largest length r such that we can have k ribbons of length r. If we cannot find ... Read More

Program to reduce list by given operation and find smallest remaining number in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 12:06:08

309 Views

Suppose we have a list of positive numbers called nums. Now consider an operation where we remove any two values a and b where a ≤ b and if a < b is valid, then insert back b-a into the list nums. If we can perform any number of operations, ... Read More

Program to count substrings with all 1s in binary string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 12:03:47

555 Views

Suppose we have a binary string s. We have to find the number of substrings that contain only "1"s. If the answer is too large, mod the result by 10^9+7.So, if the input is like s = "100111", then the output will be 7, because the substrings containing only "1"s ... Read More

Program to count number of square submatrices in given binary matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 12:01:36

468 Views

Suppose we have a 2D binary matrix. We have to find the total number of square submatrices present in matrix, where all elements are 1.So, if the input is like011011then the output will be 5, because there is one (2 × 2) square, and four (1 × 1) squaresTo solve ... Read More

Program to count number of intervals that is totally contained inside other intervals in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 11:56:48

550 Views

Suppose we have a list of intervals. In this list interval[i] has [start, end] values. We have to find the number of intervals are contained by another interval. If there is an interval that is contained by multiple other intervals that should only be counted once. An interval [s0, e0] ... Read More

Program to find all contiguously increasing numbers in start end range in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 11:54:03

425 Views

Suppose we have two numbers start and end, we have to find a sorted list of integers such that every number e in range [start, end] both inclusive and the digits of e are contiguously increasing. An example of continuously increasing number is 5678, but 169 is not.So, if the ... Read More

Program to count number of ways to win at most k consecutive games in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 10:55:26

317 Views

Suppose we have two numbers n and k. Here n represents the number of games we are going to play. We have to find in how many ways we can win k or fewer games consecutively. If the answer is too large then mod the result by 10^9 + 7.So, ... Read More

Program to find out the number of submatrices from a matrix where the sum of elements is equal to a specific value in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 16-Oct-2021 12:08:35

277 Views

Suppose we are given a matrix that contains integer values. We have to find out the submatrices from the matrix where the sum of elements of the matrices is equal to a given target sum value. We return the number of submatrices.So, if the input is like0010010001011101and target = 5, ... Read More

Program to find out the number of non-zero submatrices in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 16-Oct-2021 12:02:14

469 Views

Suppose we are given a matrix that contains only two values; 1s and 0s. We have to find out the number of submatrices in the given matrix that contains all 1s. We print the value as output.So, if the input is like0010010001011101then the output will be 12.To solve this, we ... Read More

Advertisements