- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 7347 Articles for C++
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
94 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
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
211 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
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
370 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
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
111 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
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
260 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
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
158 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
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
178 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
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
385 Views
In this article, we will discuss counting the number of unique triplets (x, y, z) in a given array of unique numbers where their XOR is 0. Thus, triplets should be unique where all the three elements are unique and would count all the combinations of triplets for example −Input : arr[ ] = { 5, 6, 7, 1, 3 } Output : 2 Explanation : triplets are { 5, 6, 3 } and { 6, 7, 1 } whose XOR is zero. Input : arr[ ] = { 3, 6, 8, 1, 5, 4 , 12} Output : ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
520 Views
Discuss how to remove an entry from HashMap using the value while iterating over it, for exampleInput: HashMap: { 1: “ Mango ”, 2: “ Orange ”, 3: “ Banana ”, 4: “Apple ” }, value=”Banana” Output: HashMap: { 1: “ Mango ”, 2: “ Orange ”, 4: “Apple ” }. Explanation: The third key-value pair is removed using the value “banana”. Input: HashMap: { 1: “Yellow”, 2: “White”, 3: “Green” }, value=”White” Output: HashMap: { 1: “Yellow”, 3: “Green” }.Approach to Find the SolutionIn C++, We can remove the element using the .erase() function. From ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
720 Views
This tutorial will discuss how to remove an entry from HashMap using the key while traversing through it. for example, Input: HashMap: { 1: “Tutorials”, 2: “Tutorials”, 3: “Point” }, key=1 Output: HashMap: { 2: “Tutorials”, 3: “Point” }. Explanation: The first element is removed using key ‘1’. Input: HashMap: { 1: “God”, ... Read More