Arnab Chakraborty has Published 4293 Articles

Word Search II in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-May-2020 14:03:03

710 Views

Suppose we have a 2D board and a list of words. So from the dictionary, we have to find all words in the board. Here each word must be constructed from letters of sequentially adjacent cell, where the adjacent cells are those horizontally or vertically neighboring. We have to keep ... Read More

Best Time to Buy and Sell Stock IV in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-May-2020 13:57:46

195 Views

Suppose we have an array for which the i-th element is the price of a given stock for the day i. We have to devise an algorithm to find the maximum profit. We can complete at most k transactions. So if the input is like [3, 2, 6, 4, 0, ... Read More

Dungeon Game in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-May-2020 13:52:55

705 Views

Suppose there is a story like the demons had captured the princess whose name is P and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M row, N column grid-like rooms. Our valiant knight named K was initially positioned in the top-left room and must ... Read More

Maximum Gap in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-May-2020 13:50:25

458 Views

Suppose we have an array, that is not sorted. We have to find the maximum difference between successive elements in its sorted form. We will return 0 if the array contains less than 2 elements. So if the array is like [12, 3, 9, 1, 17], then the output will ... Read More

Find Minimum in Rotated Sorted Array II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-May-2020 13:47:17

340 Views

Suppose we have an array that is sorted, now that is rotated at some pivot. The pivot is not known before. We have to find the minimum element from that array. So if the array is like [4, 5, 5, 5, 6, 8, 2, 3, 4], then the minimum element ... Read More

Max Points on a Line in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-May-2020 13:43:46

588 Views

Suppose we have a 2D plane. We have to find the maximum number of points that reside on the same straight line. So if the points are like −Then there are 4 pointsTo solve this, we will follow these steps −n := number of points, if n < 3, then ... Read More

Binary Tree Postorder Traversal in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-May-2020 13:40:45

1K+ Views

Suppose we have a binary tree. We have to find the post order traversal of this tree using the iterative approach. So if the tree is like −Then the output will be: [9, 15, 7, 10, -10]To solve this, we will follow these steps −if root is null, then return ... Read More

Word Break II in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-May-2020 13:37:37

492 Views

Suppose we have a non-empty string s and a dictionary called wordDict, this dictionary is containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. We have to find all such possible sentences. “appleraincoat” and dictionary is [“app”, ... Read More

Candy in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-May-2020 13:35:46

562 Views

Suppose there are N children, they are standing in a line. Here each child is assigned a rating value. We are supplying candies to these children subjected to the following requirements −Each child must have at least one candy.Children whose rating is high will get more candies than their neighbors.We ... Read More

Palindrome Partitioning II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 26-May-2020 13:14:32

178 Views

Suppose we have a string s, we have to find the number of cuts needed to divide this string into different substring and each part is a palindrome. So if the string is like “ababba”, then this will take 2 cuts. [aba|bb|a]To solve this, we will follow these steps −n ... Read More

Advertisements