Arnab Chakraborty has Published 4452 Articles

Program to find minimum costs needed to fill fruits in optimized way in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 13:13:11

1K+ Views

Suppose we have a list called fruits and another two values k and cap. Where each fruits[i] has three values: [c, s, t], this indicates fruit i costs c each, size of each of them is s, and there is total t of them. The k represents number of fruit ... Read More

Program to find minimum cost to send same number of people to two different cities in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 13:10:29

104 Views

Suppose we have a list called costs. Where costs[i] has [c1, c2] indicates that for person i it costs c1 amount to reach city 0 and costs c2 amount to reach city 1. We want the same number of people to go to city 0 as city 1, we have ... Read More

Program to check first player can win by reaching total sum to target in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 13:08:29

143 Views

Suppose we have two numbers k and target. Now consider Amal and Bimal are playing a game. In each round Amal picks a number from 1 to k to add to the total score that initially starts from 0. Whoever crosses the total to target wins. Amal always plays first, ... Read More

Program to find indices or local peaks in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 13:06:24

148 Views

Suppose we have a list of numbers called nums. We have to find the index of every peak element in the nums, sorted in ascending order. An index i of a peak element when all of these three conditions are satisfied: 1. The next number on its right that's different ... Read More

Program to find sum of the minimums of each sublist from a list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 13:04:07

190 Views

Suppose we have a list of numbers called nums. We have to find the sum of minimum of x for every sublist x in nums. If the answer is too large, then mod the result by 10^9 + 7.So, if the input is like nums = [5, 10, 20, 10, ... Read More

Program to check every sublist in a list containing at least one unique element in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 12:59:38

221 Views

Suppose we have a list of elements called nums, we have to check whether every sublist has at least 1 element in it that occurs exactly once in the sublist or not. We have to solve this problem in linear time.So, if the input is like nums = [5, 10, ... Read More

Minimum number of moves to escape maze matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 12:57:28

742 Views

Suppose we have a binary matrix, where 0 is representing an empty cell, and 1 is a wall. If we start from top left corner (0, 0), we have to find the minimum number of cells it would take to get to bottom right corner (R-1, C-1) Here R is ... Read More

Program to find number of quadruples for which product of first and last pairs are same in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 12:51:58

203 Views

Suppose we have a list of numbers called nums, with unique positive numbers nums. We have to find the number of quadruples like (a, b, c, d) from nums such that a*b = c*d, a, b, c and d all are distinct elements of nums.So, if the input is like ... Read More

Program to find number of operations needed to make pairs from first and last side are with same sum in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 12:49:34

47 Views

Suppose we have a list of numbers called nums. The length of this list is even. Now consider an operation where we select any number in nums and update it with a value in range [1 and maximum of nums]. We have to find the minimum number of such operations ... Read More

Program to find number of elements can be removed to make odd and even indexed elements sum equal in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 12:44:44

502 Views

Suppose we have a list of numbers called nums. Now consider a function say f(i) which deletes the element at index i and then returns true or false, depending the resulting list's sum of even index values is same as the sum of odd index values or not. So we ... Read More

Advertisements