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
C++ Articles - Page 162 of 719
280 Views
Discuss a problem where we are given a number N, and we need to split this number in the maximum prime numbers sum, for exampleInput: N = 7 Output: 2 2 3 Explanation: 7 can be represented as the sum of two 2’s and a 3 which are the maximum possible prime numbers. Input : N = 17 Output: 2 2 2 2 2 2 2 3Approach to Find the SolutionTo represent a number in prime numbers, we can subtract a prime number with N and check the difference for prime. If the difference is prime, then we can ... Read More
894 Views
In this article, we will discuss the problem to find the numbers from 1 to n(given) which are can not be divided by any number from 2 to 10. Let's understand this with some examples −Input : num = 14 Output : 3 Explanation: There are three numbers, 1, 11, and 13, which are not divisible. Input : num = 21 Output : 5 Explanation: There are five numbers 1, 11, 13, 17, and 19, which are not divisible.Approach to find The SolutionSimple ApproachIf we check every number from 1 to num, whether it can be divided by any ... Read More
448 Views
Discuss How to represent a set of points by the best possible straight line. We are given values (x, y) of a set of points, and we need to find the best straight line y = mx + c, So all we need is to find the value of m and c, for exampleInput: no_of_points = 4 x1 = 2, y1 = 3, x2 = 5, y2 = 6, x3 = 1, y3 = 3, x4 = 4, y4 = 5. Output: m = 0.8, c = 1.85 Explanation: If we apply the value of m and c in ... Read More
158 Views
In the given problem we need to find the value of a number which has all of the set bits between the given range L, R. For example −Input: L = 1, R = 5 Output: 62 Explanation: representation of given L and R in binary form is 0..0111110 Input: L = 1, R = 4 Output: 30 Explanation: representation of given L and R in binary form is 0..11110Approach to find The SolutionIn the given problem, we are going to discuss two approaches, Brute Force and Efficient Approach.Brute ForceIn this approach, we are simply going to traverse through ... Read More
279 Views
Discuss the way to remove functions that will remove forbidden characters like [ ‘ : ’, ‘ ? ‘, ‘ \ ’, ‘ / ’, ‘ < ’, ‘ > ’, ‘ | ’, ‘ * ’ ] from a string, for exampleInput: str = “ Hello: Welco*me/ to Tu>torials point|. ” Output: “ Hello Welcome to Tutorials point. ” Explanation: Input String contains forbidden characters which got removed and new string has no forbidden characters. Input: str = “ How/ are y*ou doi, ng? ” Output: “ How are you doing ”Approach to Find the SolutionA simple approach ... Read More
536 Views
Discuss a problem in which we are given a binary number. We have to remove a bit from it so that the remaining number should be the maximum of all the other options, for exampleInput : N = 1011 Output: 111 Explanation: We need to remove one bit so removing 0 bit will give a maximum number than removing any 1’s bit. 111 > 101, 011. Input: 111 Output: 11 Explanation: Since all the bits are 1 so we can remove any bit.Approach to Find the SolutionBrute-Force MethodApplying brute force will give the maximum resultant number, i.e., by removing ... Read More
184 Views
Given a tree, and we need to remove the leaf node of the path having a length less than the given k, for example.Input −K = 4.Output −ExplanationThe paths were : 1. A -> B -> C -> E length = 4 2. A -> B -> C -> F length = 4 3. A -> B -> D length = 3 4. A -> G -> H length = 3 5. A -> B -> I length = 3 Now as you can see paths 3, 4, 5 have length of 3 which is less than given k so ... Read More
447 Views
An integer number that can be completely divided by 2 is an even number. So in this article we are given the number n, and we need to find the nth number with an even sum of digits. The First five numbers with an even sum of digits are 2, 4, 6, 8, and 11. For example −Input : n = 5 Output : 11 Explanation : First 5 numbers with even sum of digits are 2, 4, 6, 8, 11 i.e 5th number is 11. Input : 12 Output : 24Approach to find The SolutionNow you will get ... Read More
254 Views
Given a parentheses sequence; now, you have to print all the possible parentheses that it can make by removing the invalid brackets, for exampleInput : str = “()())()” - Output : ()()() (())() There are two possible solutions "()()()" and "(())()" Input : str = (v)())() Output : (v)()() (v())()In this problem, we are going to use backtracking so that it will print all the valid sequences.Approach to Find the SolutionIn this approach, we will be trying to remove the opening and closing brackets one by one using BFS. Now for each sequence, we check if it is valid ... Read More
269 Views
In this article, we are given a question in which we need to find the total number of ways from point A to B where A and B are fixed points, i.e., A is the top-left point in the grid and B is the bottom right point in the grid for example −Input : N = 5 Output : 252 Input : N = 4 Output : 70 Input : N = 3 Output : 20In the given problem, we can formalize the answer by simple observations and get our results.Approach to find The SolutionIn this approach, we ... Read More