Arnab Chakraborty has Published 4293 Articles

Program to count minimum number of operations to flip columns to make target in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 14:06:56

222 Views

Suppose we have a matrix M and a target matrix T with the same number of rows and columns. Now suppose an operation where we flip a particular column in matrix so that all 1s will be converted to 0s and all 0s will be converted to 1s. So if ... Read More

Program to count number of operations required to all cells into same color in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 13:53:12

228 Views

Suppose we have a two-dimensional matrix M. Now in each cell contains a value that represents its color, and adjacent cells (top, bottom, left, right) with the same color are to be grouped together. Now, consider an operation where we set all cells in one group to some color. Then ... Read More

Program to find maximum number of coins we can collect in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 13:45:25

2K+ Views

Suppose we have a 2D matrix where each cell stores some coins. If we start from [0, 0], and can only move right or down, we have to find the maximum number of coins we can collect by the bottom right corner.So, if the input is like14220005then the output will ... Read More

Program to find largest sum of any path of a binary tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 13:19:36

157 Views

Suppose we have a binary tree, we have to find the largest sum of any path that goes from the root node to the leaf node.So, if the input is likethen the output will be 29 as from root, if we follow the path 5-

Program to find circular greater element to the right in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 13:09:30

175 Views

Suppose we have a list of numbers called nums. We have to find a new list of the same length where the value at index i is assigned to the next element greater than nums[i] to its right, circling back to the front of the list when required. If there ... Read More

Program to find the middle node of a singly linked list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 13:04:38

294 Views

Suppose we have a singly linked list node, we have to find the value of the middle node. And when there are two middle nodes, then we will return the second one. We have to try to solve this in single pass.So, if the input is like [5, 9, 6, ... Read More

Program to find minimum number of busses are required to pass through all stops in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 12:35:51

2K+ Views

Suppose we have a list of numbers called nums and that is showing the bus stops on a line where nums[i] shows the time a bus must arrive at station i. Now that buses can only move forward, we have to find the minimum number of buses that are needed ... Read More

Program to arrange cards so that they can be revealed in ascending order in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 12:33:31

474 Views

Suppose we have a list of cards, and we want to order the cards in a way so that they are revealed in ascending order. As we know, the cards are revealed in this manner: 1. The top most card is removed and revealed and then next card is gone ... Read More

Program to partition two strings such that each partition forms anagram in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 12:32:08

533 Views

Suppose we have two non-empty strings s and t that are of the same length. We have to partition them into substrings such that each pair of s and t substring is the same size and they are the anagrams of each other. Now find the cut indexes such that ... Read More

Program to find sum of the sum of all contiguous sublists in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 05-Oct-2020 12:30:30

422 Views

Suppose we have a list of numbers called nums, now consider every contiguous subarray. Sum each of these subarray and return the sum of all these values. Finally, mod the result by 10 ** 9 + 7.So, if the input is like nums = [3, 4, 6], then the output ... Read More

Advertisements