Arnab Chakraborty has Published 4293 Articles

Validate Stack Sequences in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 10:09:17

420 Views

Suppose we have two sequences pushed and popped with distinct values, we have to find true if and only if this could have been the result of a sequence of the push and pop operations on an initially empty stack. So if the input is push = [1, 2, 3, ... Read More

Maximum Sum Circular Subarray in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 10:06:27

271 Views

Suppose we have a circular array C of integers represented by A, we have to find the maximum possible sum of a non-empty subarray of C. Also, a subarray may only include each element of the fixed buffer A at most once. If the array is like [1, -2, 3, ... Read More

Binary Tree Pruning in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 10:04:21

675 Views

Suppose we have the head node root of a binary tree, where additionally every node's value is either a 0 or a 1. We have to find the same tree where every subtree not containing a 1 has been deleted. So if the tree is like −To solve this, we ... Read More

Maximum Width of Binary Tree in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 09:59:28

200 Views

Suppose we have a binary tree, we have to define a function to get the maximum width of the given tree. Here the width of a tree is the maximum width among all levels. We will consider the binary tree has the same structure as a full binary tree, but ... Read More

K-Concatenation Maximum Sum in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 09:28:30

307 Views

Suppose we have an integer array arr and one integer k, we have to change the array by repeating it k times. So if arr = [1, 2] and k = 3 then the modified array will be [1, 2, 1, 2, 1, 2].Now we have to find the maximum ... Read More

Invalid Transactions in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 09:25:30

226 Views

Suppose there are some transactions. A transaction is possibly invalid if −The amount exceeds $1000, or;If it occurs within (and including) 60 minutes of another transaction with the same name in a different city.Here each transaction string transactions[i] consists of comma separated values representing the name, time (in minutes), amount, ... Read More

As Far from Land as Possible in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 09:21:47

332 Views

Suppose we have one N x N grid containing only values like 0 and 1, where 0 represents water and 1 represents the land, we have to find a water cell such that its distance to the nearest land cell is maximized and return the distance. Here we will use ... Read More

Camelcase Matching in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 09:17:22

786 Views

Suppose we have a list of queries, and a pattern, we have to return an answer that will be list of booleans, where answer[i] is true if and only if queries[i] matches the pattern. A query word matches a given pattern when we can insert lowercase letters to the pattern ... Read More

Minimum Swaps To Make Sequences Increasing in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 09:14:29

337 Views

Suppose we have two integer sequences A and B of the same non-zero length. We can swap elements A[i] and B[i]. We have to keep in mind that both elements are in the same index position in their respective sequences. After completing some number of swaps, A and B are ... Read More

All Paths From Source to Target in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 09:11:33

514 Views

Suppose we have a directed, acyclic graph with N nodes. We have to find all possible paths from node 0 to node N-1, and return them in any order. The graph is given as follows: the nodes are 0, 1, ..., graph.length - 1. graph[i] is a list of all ... Read More

Advertisements