Arnab Chakraborty has Published 4293 Articles

Program to Find Out the Number of Moves to Reach the Finish Line in Python

Arnab Chakraborty

Arnab Chakraborty

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

229 Views

Suppose, we have a car and are driving it on a one−dimensional road. Currently we are at position = 0 and with speed = 1. We can perform any of these two operations.Acceleration: position := position + speed and speed := speed * 2 Reverse Gear: speed := −1 when ... Read More

Program to Find Out the Probability of Having n or Fewer Points in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:24:25

130 Views

Suppose we are playing a unique game and we have three values n, k, and h. We start from 0 points, then we can select a number randomly between 1 and h (inclusive) and we will get that many points. We stop when we have scored a minimum of k ... Read More

Program to Find Out a Sequence with Equivalent Frequencies in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-Dec-2020 11:22:21

173 Views

Suppose we have a list of numbers. We have to find the length of the longest sequence of numbers such that when we delete a number from the sequence, each number occurs the same number of times.So, if the input is like numbers = [2, 4, 4, 7, 7, 6, ... Read More

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

216 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

160 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

316 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

411 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

299 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

177 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

190 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

Advertisements