Arnab Chakraborty has Published 4452 Articles

Program to find maximum profit we can make after k Buy and Sell in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Dec-2020 05:34:22

154 Views

Suppose we have a list of numbers called nums that is representing the stock prices of a company in chronological order and we also have another value k, we have to find the maximum profit we can make from up to k buys and sells (We must buy before sell, ... Read More

Program to find minimum cost to reach final index with at most k steps in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:50:04

160 Views

Suppose we have a list of numbers nums and another value k. Here the items at nums[i] represents the costs of landing at index i. If we start from index 0 and end at the last index of nums. In each step we can jump from some position X to ... Read More

Program to find maximum profit after buying and selling stocks at most two times in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:48:17

201 Views

Suppose we have a list of numbers called prices and that is representing the stock prices of a company in chronological order, we have to find the maximum profit we can make from buying and selling that stock at most two times. We have to buy first then sell.So, if ... Read More

Program to check a string can be broken into given list of words or not in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:47:04

507 Views

Suppose we have a word list and another string s with no spaces. We have to check whether the string can be broken down using the list of words or not.So, if the input is like words = ["love", "python", "we", "programming", "language"] s = "welovepythonprogramming", then the output will ... Read More

Program to find maximum number of boxes we can fit inside another boxes in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:45:08

855 Views

Suppose we have a list of boxes where each row represents the height and width of given boxes. We can put a box in another box if first box is smaller than the second one (when both of its width and height are smaller than the other box), we have ... Read More

Program to find length of longest consecutive path of a binary tree in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:43:20

163 Views

Suppose we have a binary tree; we have to find the longest path in the binary tree.So, if the input is likethen the output will be 5 as longest consecutive sequence is [2, 3, 4, 5, 6].To solve this, we will follow these steps −if root is null, thenreturn 0maxPath ... Read More

Program to make almost BST to exact BST in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:40:59

133 Views

Suppose we have a binary tree and that is almost a binary search tree. Only two nodes' value are swapped. We have to correct it and return the binary search tree.So, if the input is likethen the output will beTo solve this, we will follow these steps −prev_node := null, ... Read More

Program to find area of largest square of 1s in a given matrix in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:38:26

595 Views

Suppose we have a binary matrix, we have to find largest square of 1s in that given matrix.So, if the input is like100001100000110111100011110001111000111100then the output will be 16.To solve this, we will follow these steps −res := 0for i in range 0 to size of matrix, dores := maximum of ... Read More

Program to find largest rectangle area under histogram in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:36:52

907 Views

Suppose we have a list of numbers representing heights of bars in a histogram. We have to find area of the largest rectangle that can be formed under the bars.So, if the input is like nums = [3, 2, 5, 7]then the output will be 10To solve this, we will ... Read More

Program to count how many numbers should be appended to create all numbers from 1 to k in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Dec-2020 05:34:56

56 Views

Suppose we have a list of numbers called nums and another value k. We have to find the minimum number of numbers that we need to insert into nums such that we can make any number from [1, k] using some subset in nums.So, if the input is like nums ... Read More

Advertisements