
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++

270 Views
Suppose we have two numbers r, c and a grid of size n x m. Some cells are in black and remaining are white. In one operation, we can select some black cells and can do exactly one of these two −Color all cells in its row black, orcolor all cells in its column black.We have to find the minimum number of operations needed to make the cells in row r and column c black. If impossible, return -1.So, if the input is likeWBWWWBBBWBWWBBBr = 0 and c = 3then the output will be 1, because we can change the ... Read More

465 Views
Suppose we have an array A with n elements, and other values l, r and k are there. Amal wants to buy chocolates and he will not buy too expensive chocolates, and not also too cheap chocolates. In the store, there are n different chocolate bars and the prices are represented in A. A chocolate bar is too expensive if its price is larger than r and too cheap if its price is less than l. He wants to spend at most k rupees. We have to find the maximum amount of chocolates he can buy.So, if the input is ... Read More

295 Views
Suppose we have an array A with n elements. In one operation, we can add 1 with any one element preset in A. If either the sum or the product of all elements in the array is equal to zero, We can do this operation one more time. We have to count the minimum number of steps needed to make both the sum and the product of all elements in the array different from zero?So, if the input is like A = [-1, 0, 0, 1], then the output will be 2, because both product and sum are 0. If ... Read More

372 Views
Suppose we have five numbers b, p, f, h and c. There are two types of burgers in a restaurant. These are hamburger and chicken burger. Hamburger needs two buns and a beef patty and for chicken burger we need two buns and a chicken cutlet. We have b buns, p beef patties, f chicken cutlets. We are trying to sell hamburger for h rupees and chicken burger for c rupees. We have to find the maximum profit that we can gain.So, if the input is like b = 7; p = 5; f = 2; h = 10; c ... Read More

167 Views
Suppose we have five numbers n, k1, k2, w and b. There is a board with 2 x n cells and first k1 cells in the first row, first k2 cells in second row are colored in white. All other cells are black. We have w white dominos and b black dominos (2 x 1 size). We can place a white domino on the board if both board's cells are white and not occupied by any other domino. In the same way, a black domino can be placed if both cells are black and not occupied by any other domino. ... Read More

445 Views
Suppose we have an array A with n elements. The A[i] represents the programming skill of ith student. All elements in A are distinct. We want to split them into teams in such a way that −No two students i and j, such that |A[i] - A[j]| = 1 belong to the same teamThe number of teams is the minimum possible.So, if the input is like A = [2, 3, 4, 99, 100], then the output will be 2, because the groups are [2, 3, 4] and [99, 100]StepsTo solve this, we will follow these steps −dem := 1 sort ... Read More

562 Views
Suppose we have an array A with n elements. There was an electronic store, where a robbery has done on the last night. All keyboards which were present inside the store were numbered in ascending order from some integer number x. For example, for x=4 and there were 3 keyboards in the store, then the devices had indices 4, 5 and 6. If x=10 and there were 7 of them then the keyboards had indices 10, 11, 12, 13, 14, 15 and 16. After the robbery, only n keyboards are left. They have indices stored in array A. We have ... Read More

162 Views
Suppose we have two arrays A with n elements and B with m elements. Select some element a form A and some element b from B, such that a + b does not belong to A or B.So, if the input is like A = [3, 2, 2]; B = [1, 5, 7, 7, 9], then the output will be [3, 1], because 3 + 1 = 4 is not present in any array. (Other answers are also available)StepsTo solve this, we will follow these steps −sort the array A sort the array B return last element of A and ... Read More

306 Views
Suppose we have a matrix containing H rows and W columns. The cells either holds '.' or '#'. The dot '.' indicates passable space, and '#' indicates block. Amal will go from his house to a market. His house is in the cell at the top-left corner, and the market is at the bottom-right corner. Amal can move one cell up, down, left, or right to a passable cell. He cannot leave the town. He cannot enter a blocked cell, either. However, his physical strength allows him to destroy all blocks in a square region with 2×2 cells of his ... Read More

219 Views
Suppose we have two numbers a and b. We have to find the smallest possible value of (a XOR x) + (b XOR x) for some value of x.So, if the input is like a = 6; b = 12, then the output will be 10, because if x = 4, then (6 XOR 4) + (12 XOR 4) = 2 + 8 = 10.StepsTo solve this, we will follow these steps −return a XOR bExampleLet us see the following implementation to get better understanding −#include using namespace std; int solve(int a, int b){ return (a^b); } int main(){ int a = 6; int b = 12; cout