Arnab Chakraborty has Published 4293 Articles

Program to find minimum number of roads we have to make to reach any city from first one in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Dec-2020 05:41:15

738 Views

Suppose we have two lists costs_from and costs_to of same size where each index i represents a city. It is making a one-way road from city i to j and their costs are costs_from[i] + costs_to[j]. We also have a list of edges where each edge contains [x, y] indicates ... Read More

Program to find minimum number of buses required to reach final target in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Dec-2020 05:38:42

362 Views

Suppose we have a n x 3 matrix where each row contains three fields [src, dest, id] this means the bus has route from src to dest. It takes one unit of money to get on a new bus, but if we stay on the same bus we have to ... Read More

Program to evaluate one mathematical expression without built-in functions in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Dec-2020 05:37:08

3K+ Views

Suppose we have a string that represents a mathematical expression with (+, -, *, /) Here / is representing integer division, we have to evaluate and return the result without using any built-in function.So, if the input is like s = "2+3*5/7", then the output will be 4, as 2 ... Read More

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

228 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

251 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

288 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

601 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

1K+ 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

244 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

185 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

Advertisements