Arnab Chakraborty has Published 4293 Articles

Number of Ways to Stay in the Same Place After Some Steps in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Jun-2020 11:00:39

272 Views

Suppose there is an array of size arrLen, and we also have a pointer at index 0 in that array. At each step, we can move 1 position to the left, 1 position to the right in the array or stay in the same place.Now suppose we have two integers ... Read More

Number of Valid Words for Each Puzzle in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Jun-2020 10:58:15

216 Views

Suppose there is a puzzle string, a word is valid if both the following conditions valid −word contains the first letter of puzzle.For each letter in word, that letter is in puzzle.Suppose if we consider an example that, if the puzzle is like "abcdefg", then valid words are "face", "cabbage" ... Read More

Recover a Tree From Preorder Traversal in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Jun-2020 10:55:14

505 Views

Suppose there is a binary tree. We will run a preorder depth first search on the root of a binary tree.At each node in this traversal, the output will be D number of dashes (Here D is the depth of this node), after that we display the value of this ... Read More

Unique Paths III in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Jun-2020 10:52:23

250 Views

Suppose we have one 2-dimensional grid, there are 4 types of squares −In a square 1 is for the starting point. There will be exactly one starting square.In a square 2 is for the ending point. There will be exactly one ending square.In a square 0 is for the empty ... Read More

Odd Even Jump in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Jun-2020 10:48:34

614 Views

Suppose we have an array A. From some starting index, we can make a series of jumps. The position (1, 3, 5, ...) jumps in the series are called odd numbered jumps, and position (2, 4, 6, ...) jumps in the series are called even numbered jumps.Now we may from ... Read More

Binary Tree Cameras in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Jun-2020 10:46:26

255 Views

Suppose we have a binary tree; we place cameras on the nodes of the tree. Now each camera at a node can monitor its parent, itself, and its children. We have to find the minimum number of cameras needed to monitor all nodes of the tree.So, if the input is ... Read More

Stamping The Sequence in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Jun-2020 10:43:06

289 Views

Suppose we want to make a target string of lowercase letters.At first, we have the sequence as n '?' marks (n is the length of target string). We also have a stamp of lowercase letters.On each turn, we can place the stamp over the sequence, and replace every letter in ... Read More

Shortest Path to Get All Keys in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Jun-2020 10:40:00

577 Views

Suppose we have a grid. There are few symbols. "." is indicating empty cell, "#" is for wall, "@" is for starting point, ("a", "b", ...) all are keys, and ("A", "B", ...) all are locks. We will start from the starting point, and one move consists of walking one ... Read More

Rectangle Area II in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Jun-2020 10:35:39

420 Views

Suppose we have a list of (axis-aligned) rectangles. Here each rectangle[i] = {x1, y1, x2, y2}, where (x1, y1) is the point of the bottom-left corner, and (x2, y2) are the point of the top-right corner of the ith rectangle.We have to find the total area covered by all rectangles ... Read More

Count Unique Characters of All Substrings of a Given String in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Jun-2020 10:32:14

627 Views

Suppose we want to define a function called countUniqueChars(s) that will return the number of unique characters on s, so if s = "HELLOWORLD" then "H", "E", "W", "R", "D" are the unique characters since they appear only once in s, therefore countUniqueChars(s) = 5.Now on this problem given a ... Read More

Advertisements