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

275 Views
Suppose we have three numbers a, b and c. We want to make a closed fence in a shape of arbitrary non-degenerate simple quadrilateral. We already have three sides of length a, b and c. We have to find another side d.So, if the input is like a = 12; b = 34; c = 56, then the output will be 42, other answers are also possible.StepsTo solve this, we will follow these steps −return a + b + c - 2ExampleLet us see the following implementation to get better understanding −#include using namespace std; int solve(int a, int ... Read More

190 Views
Suppose we have the adjacency matrix of a directed graph G. Until the graph becomes empty, we are repeating the following operation: Select one vertex from G, then erase that vertex and all vertices that are reachable from that vertex by following some edges. Erasing a vertex will also erase the edges incident to it. We have to find the expected number of times the operation is doneSo, if the input is likethen the output will be 1.6667, because initially select vertex A, remove all vertices, if we select vertex B, remove B and C, and in second operation select ... Read More

143 Views
Suppose we have a number d. Consider there is an infinite number of square tiles and regular triangular tiles with sides length 1. We have to find in how many ways we can form regular dodecagon (12-sided polygon) with sides d using these tiles. If the answer is too large, return result mod 998244353.StepsTo solve this, we will follow these steps−b := floor of d/2 - 1 c := 1 for initialize i := 2, when i < d, update (increase i by 1), do: b := b * (floor of d/2) c := c * i return ... Read More

194 Views
Suppose we have a number n. We need to find two integers l and r, such that l < r and l + (l + 1) + ... + (r - 1) + r = n.So, if the input is like n = 25, then the output will be l = -2 and r = 7, because (−2) + (−1) + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 = 25. Other answers are also possible.StepsTo solve this, we will follow these steps −return -(n-1) and nExampleLet us see the following implementation to get better understanding −#include using namespace std; void solve(int n){ cout

116 Views
Suppose we have a number R, represents the radius of a pond. We have to find the circumference of this pond.So, if the input is like R = 73, then the output will be 458.67252742410977361942StepsTo solve this, we will follow these steps −res := r * 2 * cos-inverse (-1) return resLet us see the following implementation to get better understandingExampleLet us see the following implementation to get better understanding −#include using namespace std; double solve(int r){ double res = r * 2 * acos(-1); return res; } int main(){ int R = 73; cout

210 Views
Suppose we have a string S with N characters. S contains only three types of characters 'A', 'B' or 'C'. We also have another integer K. We have to print S after lowercasing the Kth character in it.So, if the input is like K = 2; S = "AABACC", then the output will be "AaBACC"StepsTo solve this, we will follow these steps −S[K - 1] = S[K - 1] + 32 return SExampleLet us see the following implementation to get better understanding −#include using namespace std; string solve(int K, string S){ S[K - 1] = S[K - ... Read More

156 Views
Suppose we have a string S with lowercase English letters. We must insert exactly one character 'a' in S. After inserting that if we can make S not a palindrome then return that string, otherwise return "impossible".So, if the input is like S = "bpapb", then the output will be "bpaapb"StepsTo solve this, we will follow these steps −if concatenation of S and "a" is not palindrome, then: return S concatenation 'a' otherwise when concatenation of "a" + S is not palindrome, then: return 'a' concatenation S Otherwise return "Impossible"ExampleLet us see the following implementation to get ... Read More

327 Views
Suppose we have two numbers N and K. We want to distribute N crackers to K users. We have to find the minimum possible difference between the largest number of crackers received by a user and smallest number received by a user.So, if the input is like N = 7; K = 3, then the output will be 1, because when the users receive two, two and three crackers, respectively, the difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.StepsTo solve this, we will follow these steps −if ... Read More

160 Views
Suppose we have two numbers K and X. Consider Amal has K, 500 rupee notes. We have to check whether the sums up to X rupees or not.So, if the input is like K = 2; X = 900, then the output will be True, because 2*500 = 1000 and it is not less than 900.StepsTo solve this, we will follow these steps −if (500 * k) >= x, then: return true Otherwise return falseExampleLet us see the following implementation to get better understanding −#include using namespace std; bool solve(int k, int x){ if ((500 * k) >= x){ return true; } else{ return false; } } int main(){ int K = 2; int X = 900; cout

296 Views
Suppose we have two arrays A and B both with N elements. Consider there are N computers and N sockets. The coordinate of ith computer is A[i] and coordinate of ith socket is b[i]. These 2N coordinates are pair-wise distinct. We want to connect each computer with a socket by cables. Each socket can be connected at most one computer. We have to count in how many ways we can minimize the length of cables. If the answer is too large, return result mod 10^9 + 7.So, if the input is like A = [0, 10]; B = [20, 30], ... Read More