Arnab Chakraborty has Published 4452 Articles

Program to find maximum profit we can get by buying and selling stocks with a fee in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 08:05:39

115 Views

Suppose we have a list of stock prices of a company in chronological sequence, and also have the transaction fee for one sell transaction. We have to find the maximum profit we could have made from buying and selling that stock any number of times. We must buy before we ... Read More

Program to find maximum number enemies will be killed to place a bomb in C++?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 08:03:05

330 Views

Suppose we have a 2D matrix of three different values, 2s, 1s, and 0s, where a 2 represents an enemy, 1 represents a wall and 0 represents an empty cell. We have to find the maximum enemies we can kill using one bomb. The bomb kills all the enemies in ... Read More

Program to find number of places are safe when bomb explodes in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 07:58:13

144 Views

Suppose we have a 2d binary matrix, where 1 represents a bomb and 0 represents an empty cell. When a bomb explodes, all the spaces along on the same row and column are damaged. We have to find the number of spaces we can stand in to not get damaged.So, ... Read More

Program to find minimum possible sum by changing 0s to 1s k times from a list of numbers in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 07:55:14

70 Views

Suppose we have a list of numbers called nums and another value k. We have to following operation k times: Select any number on the list. In the binary representation of that number, select a bit that is 0 and make it 1. Finally, we have to return the minimum ... Read More

Program to find starting index of the child who receives last balloon in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 07:50:58

55 Views

Suppose we have n children standing in a circle, and they are waiting to get a balloon. The distribution is carried out starting with the kth child (first at index 0), and giving them a balloon they left the circle. Now every kth child gets a balloon going clockwise until ... Read More

Program to convert binary search tree to a singly linked list in C++?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 07:46:56

496 Views

Suppose we have a binary tree; we have to convert this into a singly linked list (in place).So, if the input is likethen the output will beTo solve this, we will follow these steps:ser prev := nullDefine a recursive function solve(), that will take root as input.if root is null, ... Read More

Program to find higher number with same number of set bits as n in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 07:40:38

126 Views

Suppose we have a number n; we have to find the smallest next higher number with the same number of 1s as n in binary form.So, if the input is like n = 7, then the output will be 11, as 7 in binary is 0111 and next higher from ... Read More

Program to find column index where left most 1 is present in a binary matrix in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 07:37:30

201 Views

Suppose we have a 2D binary matrix. Here each row is sorted in ascending order with 0s coming before 1s, we have to find the leftmost column index with the value of 1. If there's no such result, return -1.So, if the input is like0001001100110010then the output will be 2, ... Read More

Program to find maximum profit we can make by buying and selling stocks in Python?

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 07:34:52

138 Views

Suppose we have a list of stock prices of a company in chronological order, we have to find the maximum profit we could have made from buying and selling the stock. We must buy before selling, and we must wait one day after selling the stock before buying again.So, if ... Read More

Program to convert linked list by alternating nodes from front and back in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 10-Nov-2020 07:31:39

117 Views

Suppose we have a singly linked list, we have to rearrange it such that we take: the last node, and then the first node, and then the second last node, and then the second node, and so on.So, if the input is like [1, 2, 3, 4, 5, 6, 7, ... Read More

Advertisements