Arnab Chakraborty has Published 4452 Articles

Program to find maximum non negative product in a matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Oct-2021 11:53:09

120 Views

Suppose we have a matrix of order m x n. Initially we are at the top-left corner cell (0, 0), and in each step, we can only move right or down in the matrix. Now among all possible paths from the top-left corner cell (0, 0) to bottom-right corner cell(m-1, ... Read More

Program to find split a string into the max number of unique substrings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Oct-2021 10:07:49

287 Views

Suppose we have a string s, we have to find the maximum number of unique substrings that the given string can be split into. We can split string s into any list of non-empty substrings such that the concatenation of the substrings forms the original string. But we must split ... Read More

Program to make sum divisible by P in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Oct-2021 10:00:07

282 Views

Suppose we have an array nums and another value p, we remove the smallest subarray (not the whole array) such that the sum of the remaining values is divisible by p. We have to find the length of the smallest subarray that we need to remove, if there is no ... Read More

Program to find maximum sum obtained of any permutation in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Oct-2021 09:44:48

334 Views

Suppose we have an array nums, and another array called requests where requests[i] = [start_i, end_i], this represents the ith request asks for the sum of nums[start_i] + nums[start_i+1] + ... + nums[end_i-1] + nums[end_i]. We have to find the maximum total sum of all requests among all permutations of ... Read More

Program to find minimum cost to connect all points in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Oct-2021 09:32:53

367 Views

Suppose we have an array called points with some points in the form (x, y). Now the cost of connecting two points (xi, yi) and (xj, yj) is the Manhattan distance between them, the formula is |xi - xj| + |yi - yj|. We have to find the minimum cost ... Read More

Program to count number of unhappy friends in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Oct-2021 09:18:51

164 Views

Suppose we have a list of preferences for n(even) different friends. For each person i, the preferences[i] holds a list of friends sorted in the order of preference. So, a friend earlier in the list is more preferred than a friend later in the list. The friends in each list ... Read More

Program to find minimum deletion cost to avoid repeating letters in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Oct-2021 08:50:25

592 Views

Suppose we have a string s and another array of integers called cost where cost[i] represents the cost of deleting the ith character in s. We have to find the minimum cost of deletions such that there are no two same letters next to each other. We have to keep ... Read More

Program to find number of ways where square of number is equal to product of two numbers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Oct-2021 08:39:40

156 Views

Suppose we have two arrays nums1 and nums2, we have to find of triplets formed (type 1 and type 2) following these two rules −Triplet (i, j, k) if nums1[i]^2 = nums2[j] * nums2[k] where [0

Program to find shortest subarray to be removed to make array sorted in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Oct-2021 08:12:57

209 Views

Suppose we have an array called arr, we have to remove a subarray of arr such that the remaining elements in arr are in non-decreasing order. We have to find the length of the shortest subarray to remove.So, if the input is like arr = [10, 20, 30, 100, 40, ... Read More

Program to find number of ways to split a string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 04-Oct-2021 08:02:11

309 Views

Suppose we have a binary string s we can split s into 3 non-empty strings s1, s2, s3 such that (s1 concatenate s2 concatenate s3 = s). We have to find the number of ways s can be split such that the number of characters '1' is the same in ... Read More

Advertisements