Arnab Chakraborty has Published 4452 Articles

Program to find length of longest valid parenthesis from given string in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 06:27:58

83 Views

Suppose we have a string s. This s consists of opening and closing parenthesis only. We have to find the length of the longest valid (well-formed) parentheses substring. So if the input is like “))(())())”, then the result will be 6, as the valid string is “(())()”.To solve this, we ... Read More

Program to find maximum price we can get by holding items into a bag in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 06:26:20

295 Views

Suppose we have two lists of numbers. One is called weights and another is called values. These are of same length, We also have two values called capacity and count. Here weights[i] and values[i] represent the weight and value of the ith item. We can hold at most capacity weight ... Read More

Program to get final position of moving animals when they stops in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 06:24:50

122 Views

Suppose we have a string s that is representing the initial conditions of some animals. Each animal can take one of three values: L, indicates the animal moved to left. R, indicates the animal moved to right. @, indicates the animal is standing still. Animals moving on a direction will ... Read More

Program to find minimum number of flips required to have alternating values in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 06:22:54

330 Views

Suppose we have a binary string s. Now suppose we can take some prefix of s and move it to the back. then, find the minimum number of characters that need to be flipped such that there will be no consecutive characters of the same value.So, if the input is ... Read More

Program to count minimum k length sublist that can be flipped to make all items of list to 0 in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 06:20:49

53 Views

Suppose we have a list of numbers called nums that stored 0s and 1s. We have another value k.Now consider there is an operation where we flip a sublist of length k such that all 1s will be 0s and all 0s will be 1s. We have to find the ... Read More

Program to find minimum radius to light up all houses on a street in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 06:18:26

500 Views

Suppose we have a list of numbers called nums that are representing position of houses on a 1-dimensional line. Now consider we have 3 street lights that we can put anywhere on the line and a light at position x lights up all houses in range [x - r, x ... Read More

Program to find minimum string size that contains given substring in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Dec-2020 14:08:50

296 Views

Suppose we have two strings s and t, we have to find the size of a minimum substring in s that contains all the characters of t. If there is no such substring exists then return -1.So, if the input is like s = "thegrumpywizardmakes" t = "wake", then the ... Read More

Program to Find Out the Maximum Points From Removals in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Dec-2020 13:16:35

199 Views

Suppose we are provided with a list of positive numbers. Now, here we can remove any contiguous sub list of some length t with the same value and get points t * t. One condition is to be considered, that we can perform this any number of times until the ... Read More

Program to Find Out the Largest K-Divisible Subsequence Sum in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Dec-2020 13:14:03

311 Views

Suppose we are given a list of non−negative numbers, and a positive value k. We have to find the maximum sum subsequence of numbers such that the sum is divisible by k.So, if the input is like, nums = [4, 6, 8, 2], k = 2, then the output will ... Read More

Program to Find the longest subsequence where the absolute difference between every adjacent element is at most k in Python.

Arnab Chakraborty

Arnab Chakraborty

Updated on 15-Dec-2020 13:12:14

358 Views

Suppose we are given a list of numbers and another value k. This time our task is to find the length of the longest subsequence where the absolute difference between every adjacent element is at most k.So, if the input is like nums = [5, 6, 2, 1, −6, 0, ... Read More

Advertisements