Arnab Chakraborty has Published 4293 Articles

Best Time to Buy and Sell Stock II in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:32:06

1K+ Views

Suppose we have an array A, here A[i] is indicating the price of a given stock on day i. We have to find the maximum profit. We can complete as many transactions as we like. (Transaction means to buy and sell stocks). But we have to keep in mind that ... Read More

Best Time to Buy and Sell Stock in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:29:33

542 Views

Suppose we have an array A, here A[i] is indicating the price of a given stock on day i. We have to find the maximum profit. We can complete at most one transaction. (Transaction means to buy and sell stocks). But we have to keep in mind that we may ... Read More

Hexspeak in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:26:59

931 Views

Suppose a decimal number can be converted to its Hexspeak representation by converting it to an uppercase hexadecimal string at first, after that replacing all occurrences of the digit 0 with the letter O, and the digit 1 with the letter I.This kind of representation is valid if and only ... Read More

Path Sum in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:24:19

693 Views

Suppose we have one tree and a sum. We have to find one path such that if we follow that path, we will get the sum that will be matched with the given sum. Suppose the tree is like [0, -3, 9, -10, null, 5] and the sum is 14, ... Read More

Minimum Path Sum in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:19:34

236 Views

Suppose we have a m x n matrix filled with non-negative integers, find a path from top left corner to bottom right corner which minimizes the sum of all numbers along its path. Movements can only be either down or right at any point in time. So for example, if ... Read More

Convert Sorted Array to Binary Search Tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:18:12

2K+ Views

Suppose we have one sorted array A. We have to generate one height-balanced binary search. In this problem, a height-balanced binary tree is actually a binary tree in which the depth of the two subtrees of every node never differs by more than 1. Suppose the array is like [-10, ... Read More

Intersection of Three Sorted Arrays in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:16:52

509 Views

Suppose there are three integer arrays arr1, arr2 and arr3 and they are sorted in strictly increasing order, we have to return a sorted array of only the integers that appeared in all of these three arrays. So if arrays are [1, 2, 3, 4, 5], [1, 2, 5, 7, ... Read More

Diet Plan Performance in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:12:55

1K+ Views

Suppose a dieter consumes calories[i], this indicates the calories on the i-th day. If we have an integer k, for every consecutive sequence of k days that is (calories[i], calories[i+1], ..., calories[i+k-1] for all 0 upper, so increase one point, lower = length of C, then come out from ... Read More

Maximum Depth of Binary Tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 09:10:53

2K+ Views

Suppose we have one binary tree. We have to find the maximum depth of that tree. The maximum depth of a tree is the maximum number of nodes that are traversed to reach the leaf from the root using the longest path. Suppose the tree is like below. The depth ... Read More

Single-Row Keyboard in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 28-Apr-2020 08:59:34

413 Views

Suppose, there is a special keyboard with all keys in a single row. So if we have a string of length 26 indicating the layout of the keyboard (indexed from 0 to 25), initially our finger is at index 0. To type a character, we have to move your finger ... Read More

Advertisements