Arnab Chakraborty has Published 4452 Articles

Program to Find Minimum Jumps Required to Reach a Value with Different Parity in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:19:42

140 Views

Suppose, we are provided with a list of numbers called nums. Here we can jump to index i + numbers[i] or to i − numbers[i] from index i if the values exist in the list. So we have to find the number of jumps required at least to reach another ... Read More

Program to find island count by adding blocks into grid one by one in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:16:42

116 Views

Suppose we have one infinite grid of water. We can add blocks of land to that grid one by one. We have a list of coordinates called land_requests where each coordinate is in the form [r, c] where r is for row and c is for column. We have to ... Read More

Program to find sum of rectangle whose sum at most k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:12:30

214 Views

Suppose we have a 2d matrix and another value k, we have to find the largest sum of a rectangle where sum ≤ k.So, if the input is like5−2710and k = 15, then the output will be 12, as we can take the rectangle [5, 7] to get sum of ... Read More

Program to construct Maximum Stack with given operations in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:11:10

253 Views

Suppose we want to make a maximum stack, which supports following operations −MaxStk() this will construct a new instance of a maximum stackpush(val) inserts val to the stacktop() get the top most element from stackmax() get the maximum element from the stackpop() removes and returns the top most element from ... Read More

Program to find maximum difference of any number and its next smaller number in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:09:09

213 Views

Suppose we have a list of numbers called nums, we have to find the maximum difference that exists between any number and the next smaller number. Our goal is to solve this in linear time.So, if the input is like nums = [14, 2, 6, 35, 12], then the output ... Read More

Program to find maximum adjacent absolute value sum after single reversal in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:07:28

97 Views

Suppose we have a list of numbers called nums and we can reverse any sublist in the list at most once. After performing this operation, we have to find the maximum possible value of$\displaystyle\sum\limits_{i=0}^{n-2}| nums[i+1]-[nums[i]|$So, if the input is like nums = [2, 4, 6], then the output will be ... Read More

Program to find largest island after changing one water cell to land cell in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:02:39

111 Views

Suppose we have a binary matrix where 1 represents land and 0 represents water. And an island is a group of 1s that are surrounded by water. We have to find the size of the largest island. We are allowed to change at most one water cell to land cell.So, ... Read More

Program to find largest average of sublist whose size at least k in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:59:53

227 Views

Suppose we have a list of numbers called nums and another value k, we have to find the largest average value of any sublist of the list whose length is at least k.So, if the input is like nums = [2, 10, -50, 4, 6, 6] k = 3, then ... Read More

Program to find kth lexicographic sequence from 1 to n of size k Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:57:54

139 Views

Suppose we have two values n and k. Now consider a list of numbers in range 1 through n [1, 2, ..., n] and generating every permutation of this list in lexicographic sequence. For example, if n = 4 we have [1234, 1243, 1324, 1342, 1423, 1432, 2134, 2143, 2314, ... Read More

Program to construct Frequency Stack in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 10:56:34

98 Views

Suppose we want to construct one stack called FrequencyStack, Our FrequencyStack has two functions −append(x), This will append or push a value x onto the stack.pop(), This will remove and returns the most frequent element in the stack. If there are more than one elements with the same frequency, then ... Read More

Advertisements