
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

190 Views
Suppose we have a square board of characters. We can move on the board starting at the bottom right square marked with the character 'S'. Now we need to reach the top left square marked with the character 'E'. The other squares are labeled either with a numeric character from 1 to 9 or with an obstacle 'X'. In one move we can go up, left or up-left only when there is no obstacle there.We have to find the list of two numbers: the first number is the maximum sum of the numeric characters we can collect, and the second ... Read More

397 Views
Suppose we have n boxes, here each box is given in the format like [status, candies, keys, containedBoxes] there are some constraints −status[i]: an is 1 when box[i] is open and 0 when box[i] is closed.candies[i]: is the number of candies in box[i].keys[i]: is an array contains the indices of the boxes we can open with the key in box[i].containedBoxes[i]: an array contains the indices of the boxes found in box[i].We will start with some boxes given in initialBoxes array. We can take all the candies in any open box and we can use the keys in it to open ... Read More

597 Views
Suppose we have a m x n grid, here each cell is either 0 or 1. 0 cell is empty and 1 is blocked. In one step, we can move up, down, left or right from and to an empty cell. We have to find the minimum number of steps to walk from the upper left corner cell (0, 0) to the lower right corner cell (m-1, n-1) given that we can eliminate at most k obstacles. If there is no such way, then return -1.So, if the input is like000110000011000and k is 1, then the output will be 6, ... Read More

299 Views
Suppose we have a grid arr, this is a square grid, a falling path with non-zero shifts is a choice of exactly one element from each row of arr, such that no two elements chosen in adjacent rows are present in the same column. We have to find the minimum sum of a falling path with nonzero shifts.So, if the input is like arr is like [[1, 2, 3], [4, 5, 6], [7, 8, 9]], then the output will be 13, as there are different falling paths, these are like [1, 5, 9], [1, 5, 7], [1, 6, 7], [1, ... Read More

271 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 steps and arrLen, we have to find the number of ways such that the pointer still at index 0 after exactly steps. If the answer is very large then return it modulo 10^9 + 7.So, if the input is like steps = 3, arrLen = 2, then the output will ... Read More

215 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" etc; but some invalid words are "beefed" as there is no "a" and "based" as there is "s" which is not present in the puzzle.We have to find the list of answers, where answer[i] is the number of words in the given word list words that are valid with respect ... Read More

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 node. As we know if the depth of a node is D, the depth of its immediate child is D+1 and the depth of the root node is 0.Another thing we have to keep in mind that if a node has only one child, that child is guaranteed to be ... Read More

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 squares and we can walk over.In a square -1 if for the obstacles that we cannot walk over.We have to find the number of 4-directional walks from the starting square to the ending square, that walk over every non-obstacle square exactly once.So, if the input is like −10000000102-1then the output ... Read More

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 index i jump forward to index j (with i < j) in this way −During odd numbered jumps, we can jump to the index j such that A[i] = A[j] and A[j] is the largest possible value. When there are multiple such indexes j, we can only jump to the ... Read More

14K+ Views
In this problem, we are given an array arr[] of n integers. Our task is to create a program to find the minimum and maximum element of an array in C++.Problem Description − Here, we have an array arr[]. The contains n integer values. We have to find the maximum value and minimum value out of all values of the array.Let’s take an example to understand the problem, Inputarr[] = {2, 1, 6, 9, 4, 10, 15, 21}Outputmax = 21 , min = 1Solution ApproachThere can be multiple solutions to the problem, One solution would be directly comparing elements of ... Read More