Arnab Chakraborty has Published 4293 Articles

Program to find maximum sum by removing K numbers from ends in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Nov-2020 05:51:18

400 Views

Suppose we have a list of numbers called nums and another value k. We have to find the maximum sum of elements that we can delete, given that we must pop exactly k times, where each pop can be from the left or the right end.So, if the input is ... Read More

Program to find maximum additive score by deleting numbers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Nov-2020 05:50:07

185 Views

Suppose we have a list of numbers called nums. Let us consider an operation where we can select a number, then remove it and increase our score by the sum of the number and its two adjacent numbers. If we can perform this operation as many times as we want ... Read More

Program to find a target value inside given matrix or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Nov-2020 05:48:13

442 Views

Suppose we have a 2D matrix, where each row and column is sorted in non-decreasing order, we have to check whether given target is present inside it or not.So, if the input is like243034316632And target = 31, then the output will be TrueTo solve this, we will follow these steps ... Read More

Program to find nth smallest number from a given matrix in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Nov-2020 05:47:00

178 Views

Suppose we have a 2D matrix, where each row and column is sorted in non-decreasing order, we have to find the nth smallest number.So, if the input is like243034316632And n = 4, then the output will be 6.To solve this, we will follow these steps −lst := a new listfor ... Read More

Program to generate matrix where each cell holds Manhattan distance from nearest 0 in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Nov-2020 05:45:39

234 Views

Suppose we have a binary matrix. We have to find the same matrix, but each cell's value will be the Manhattan distance to the nearest 0. We can assume at least one 0 exists in the matrix.So, if the input is like101101110then the output will be101101210as only the bottom left ... Read More

Program to find number of combinations of coins to reach target in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Nov-2020 05:43:36

1K+ Views

Suppose we have a list of coins and another value amount, we have to find the number of combinations there are that sum to amount. If the answer is very large, then mod the result by 10^9 + 7.So, if the input is like coins = [2, 5] amount = ... Read More

Program to find lowest sum of pairs greater than given target in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 20-Nov-2020 05:40:22

256 Views

Suppose we have a list of numbers called nums and another value target. We have to find the lowest sum of pair of numbers that is larger than target.So, if the input is like nums = [2, 4, 6, 10, 14] target = 10, then the output will be 12, ... Read More

Lonely Pixel I in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 10:17:47

225 Views

Suppose we have a picture consisting of black and white pixels, we have to find the number of black lonely pixels. Here the picture is represented by a 2D char array consisting of 'B' and 'W', for the black and white pixels respectively.A black lonely pixel is actually 'B' that ... Read More

Inorder Successor in BST II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 10:15:29

388 Views

Suppose we have a node in a binary search tree, we have to find the in-order successor of that node in the BST. If there is no in-order successor, return null. As we know that the successor of a node is the node with the smallest key greater than value ... Read More

The Maze II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 19-Nov-2020 10:13:27

540 Views

Suppose there is a ball in a maze with empty spaces and walls. Now the ball can go through empty paths by rolling any direction like up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction.We ... Read More

Advertisements