- 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++
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
350 Views
In this tutorial, we are going to find the partition point in an array where all the elements left to the partition point are small and all the elements right to the partition point are large.Let's see the steps to solve the problem.Initialize the array.Iterate over the array.Iterate from 0 to I and check each value whether it is smaller than the current value or not.Iterate from I to n and check each value whether it is larger than the current value or not.If the bot the conditions satisfied, then return the value.Print the partition point.ExampleLet's see the code. Live Demo#include ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
136 Views
In this tutorial, we are going to write a program that finds the pair whose sum is equal to the given number in the binary search tree.We are going to store and values of trees in two different lists to find the pairs. Let's see the steps to solve the problem.Create a struct node for a binary tree.Write a function to insert a new node into the binary search tree.Remember, in the binary search tree all the elements that are less than root are smaller, and right are larger.Initialize two empty lists to store the left and right nodes of ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
141 Views
In this tutorial, we are going to find a number whose some including with its digits is equal to the given number N.The idea is simple, we are going to check the left and right 100 numbers of the given number. It won't lie out that bound as N ≤ 1000000000 and the sum won't exceed 100.Let's see the steps to solve the problem.Initialize the number.Write a loop that iterates 100 times.Get the n - i and n + i values.Find the sum of the digits and add them.If anyone of them is equal to the N, print them.ExampleLet's see ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
123 Views
In this tutorial, we are going to find the number that is divided into maximum elements in the given array.Let's see the steps to solve the problem.Initialize the array and a variable to store the result.Iterate over the array.Initialize the counter variable.Iterate over the array again.Increment the counter if the current element is divisible by the array element.Update the result if the current count is maximum.Print the result.ExampleLet's see the code. Live Demo#include using namespace std; int numberWithMaximumMultiples(int arr[], int n) { int result = -1; for (int i = 0; i < n; i++) { ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
199 Views
In this tutorial, we are going to solve the following problem.Given an array, find the number which is equal to the index. It's a straightforward problem.Iterate over the given array and return the index which is equal to the array element.ExampleLet's see the code. Live Demo#include using namespace std; int linearSearch(int arr[], int n) { for(int i = 0; i < n; i++) { if(arr[i] == i) { return i; } } return -1; } int main() { int arr[] = {10, 20, 30, 40, 50, 5, 60}; cout
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
208 Views
In this tutorial, we are going to solve the following problem.Given an integer n, we have to find the (1n+2n+3n+4n)%5The number (1n+2n+3n+4n) will be very large if n is large. It can't be fit in the long integers as well. So, we need to find an alternate solution.If you solve the equation for the number 1, 2, 3, 4, 5, 6, 7, 8, 9 you will get 10, 30, 100, 354, 1300, 4890, 18700, 72354, 282340 values respectively.Observe the results of the equation carefully. You will find that the last digit of the equation result repeats for every 4th number. ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
76 Views
In this tutorial, we are going to write a program to evaluate the equation 2^(2^A) % B.We are going to find the value of the equation using a recursive function. Let's see the steps to solve the problem.Write a recursive function that takes 2 arguments A and B.If A is 1, then return 4 % B as 2^(2^1) % B = 4 % B.Else recursively call the function with A-1 and b.Return the result^2%B.Print the solutionExampleLet's see the code. Live Demo#include using namespace std; long long solveTheEquation(long long A, long long B) { // 2^(2^1) % B = 4 ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
98 Views
In this tutorial, we are going to solve the below problem.Given an array of integers, we have to find two numbers A and B. All the remaining numbers in the array are the divisors of A and B.If a number is a divisor of both A and B, then it will present twice in the array.Let's see the steps to solve the problem.The max number in the array is one of the numbers from A and B. Let's say it is A.Now, B will be the second-largest number or the number which is not a divisor of A.ExampleLet's see the ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
144 Views
In this tutorial, we are going to solve the equation (ab)%m where a is a very large number.The equation (ab)%m=(a%m)*(a%m)...b_times. We can solve the problem by finding the value of a%m and then multiplying it b times.Let's see the steps to solve the problem.Initialize the numbers a, b, and m.Write a function to find the a%m.Initialize the number with 0.Iterate over the number in string format.Add the last digits to the number.Update the number with number modulo them.Get the value of a%m.Write a loop that iterates b times.Multiply the a%m and modulo the result with m.Print the result.ExampleLet's see the ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
148 Views
In this tutorial, we are going to solve the following problem.Given a string containing only characters a and b, our task is to delete the sub-string ab from the string. And print the remaining string.Here, the idea is very simple to solve the problem. Every string with only a's and b's will shrink to either a's or b's at the end.Let's see the steps to solve the problem.Initialize the string.Initialize two counter variables for a and b.Iterate over the given string.Count the a's and b'sFind the maximum from the a and b frequencies.Print the difference between the two.ExampleLet's see the ... Read More