Arnab Chakraborty has Published 4293 Articles

Program to find number of operations needed to decrease n to 0 in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 06:38:57

206 Views

Suppose we have a number n. Now consider an operation where we can either 1. Decrement n by one 2. If n is even number, then decrement it by n / 2 3. If n is divisible by 3, then decrement by 2 * (n / 3) Finally find the ... Read More

Program to get next integer permutation of a number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 22-Dec-2020 06:36:12

445 Views

Suppose we have a number n, we have to find the next bigger permutation of its digits. When n is already in its largest permutation, then rotate it down to the smallest permutation.So, if the input is like n = 319, then the output will be 391.To solve this, we ... Read More

Program to check whether we can get N queens solution or not in Python

Arnab Chakraborty

Arnab Chakraborty

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

257 Views

Suppose we have a binary matrix where 0 is representing empty cell and 1 is representing a chess queen at that cell. We have to check whether we can fill this board and get a valid nqueen solution or not. As we know the n queens puzzle asks to place ... Read More

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

130 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

360 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

212 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

421 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

123 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

700 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

410 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

Advertisements