Arnab Chakraborty has Published 4293 Articles

Program to count number of overlapping islands in two maps in Python

Arnab Chakraborty

Arnab Chakraborty

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

169 Views

Suppose we have two binary matrices mat1 and mat2. Here 1 represents land and 0 represents water, if there is a group of 1(land) surrounded by water is called island. We have to find the number of islands that exist in both mat1 and mat2 at the exact same coordinates.So, ... Read More

Program to find index, where we can insert element to keep list sorted in Python

Arnab Chakraborty

Arnab Chakraborty

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

700 Views

Suppose we have a list of numbers called nums, they are sorted in ascending order, we also have another number target, we have to find the index where target should be inserted to keep nums sorted. If target already present in nums, then return the largest index where target can ... Read More

Program to find how many updates required to make string half monotonous in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 18-Oct-2021 13:15:56

162 Views

Suppose we have a lowercase string s whose length is even. We have to find the minimum number of characters that need to be updated such that one of the following three conditions is satisfied for all i, where 0 ≤ i < n/2 and j, n/2 ≤ j < ... Read More

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

2K+ 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

173 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

218 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

246 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

300 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

320 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

1K+ 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

Advertisements