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

229 Views
Suppose we have a number n. In a game initially the value of n is v and the player is able to do the following operation zero or more times: Select a positive integer x that x < n and x is not a divisor of n, then subtract x from n. The goal of the player is to minimize the value of n in the end.So, if the input is like n = 8, then the output will be 1, because the player can select x = 3 in the first turn, then n becomes 5. We can then ... Read More

325 Views
Suppose we have two arrays A of size n, and B of size m, and another number r. There are n opportunities to buy shares. The i-th of them allows to buy as many shares as we want, ith share price is A[i]. And also there are m opportunities to sell shares. The i-th of them allows to sell as many shares as we want, sell price of ith share is B[i]. We can't sell more shares than we have. If we have r amount of money and no existing share, we have to find the maximum number of money ... Read More

142 Views
Suppose we have an array A with n elements. There is another hidden array B of size n. The elements can be negative or positive. For each index i in range 1 to n, following operations will be performed −Set A[i] as 0 initiallyThen add B[i] to A[i], subtract B[i+1], then add B[i+2] and so onWe have to find the array B.So, if the input is like A = [6, -4, 8, -2, 3], then the output will be [2, 4, 6, 1, 3]StepsTo solve this, we will follow these steps −for initialize i := 0, when i < size ... Read More

283 Views
Suppose we have a string S with n characters. The characters will be either '+' or '-'. There is a pile of stones, n times we either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile. We have to find the minimal possible number of stones that can be in the pile after making these operations. If we took the stone on i-th operation, S[i] is equal to "-", if added, S[i] is equal to "+".So, if the input is like S ... Read More

299 Views
Suppose we have a string S of size n and another number k. The string contains four types of characters. Consider there are few cells, a grasshopper wants to jump to reach the target. Character '.' means that the corresponding cell is empty, character '#' means that the corresponding cell contains an obstacle and grasshopper can't jump there. 'G' means that the grasshopper starts at this position and, 'T' means that the target cell. The grasshopper is able to jump exactly k cells away from its current position. We have to check whether the grasshopper can jump to the target ... Read More

277 Views
Suppose we have an array A with n elements. We need to paint elements in colors such that −If we consider any color, all elements of this color must be divisible by the minimal element of the same color.The number of used colors should be minimized.We have to find the minimum number of colors to paint all the given numbers in a valid way.So, if the input is like A = [10, 2, 3, 5, 4, 2], then the output will be 3, because paint the first color to the elements A[0] and A[3], paint second color to the elements ... Read More

168 Views
Suppose we have five numbers in an array T. There are five cards and each card has a number written on them. The ith card has T[i] written on it. We can discard some cards and our goal is to minimize the sum of numbers written on remaining numbers. He is allowed to at most once discard two or three cards with the same number. We won't discard cards if it's impossible to choose two or three cards with the same number. We have to find the minimum sum possible.So, if the input is like T = [7, 3, 7, ... Read More

335 Views
Suppose, we are given two points a = (x1, y1) and b = (x2, y2). The Manhattan distance between two points is dist(a, b) = |x1 - x2| + |y1 - y2|. If the point a's coordinate is (0, 0) and the point b's coordinate is (x, y), we have to find a point c such that dist(a, c) = dist(a, b)/ 2 and dist(b, c) = dist(a, b)/2. If a point like that is not available then, we print -1, -1.So, if the input is like x = 13, y = 7, then the output will be 6, 4.StepsTo ... Read More

832 Views
Suppose, we are performing a physics experiment. We are given n pairs of values and a threshold value k. Each the first value of the pair is added to a total value and the second value of the pair is also added to another total value. Now, we check if a total value is minimum or the (k - total) value is minimum. We do this for both the totals and then add them and print the output.So, if the input is like n = 4, k = 20, values = {{3, 5}, {4, 3}, {2, 1}, {4, 4}}, then ... Read More

472 Views
Suppose, we are given two k-digit numbers m and n. The digits of the numbers are randomly shuffled and then compared. We have to find out which number has a higher probability to be greater.So, if the input is like n = 231, m = 337, k = 3, then the output will be ‘Second’, or the second number has a higher probability to be greater.StepsTo solve this, we will follow these steps −s1 := convert n to string s2 := convert m to string f := 0, s = 0 for initialize i := 0, when i < k, ... Read More