- 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++
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
138 Views
Suppose, we have n pairs of boxes that need to be shipped in a square-shaped container. The width of the pair of the boxes is given as a pair (a, b) and they are given in an array 'dimensions'. If we keep the width of the boxes parallel to each other, we have to find out how much area the boxes will take inside the container. We cannot stack the boxes on top of each other. We determine the minimum area required by the two boxes in the container for all the n pairs.So, if the input is like n ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
324 Views
Suppose, there is a two-player game that has n rounds. The scores of the rounds are given in an array 'scores' where each element is of the format {P1 Score, P2 Score}. The player with the higher score wins a round, and a player wins the game if they have won more rounds; otherwise, it is declared as a draw. So, given the scores, we have to find out who has won the game.So, if the input is like n = 4, scores = {{4, 3}, {3, 2}, {5, 6}, {2, 5}}, then the output will be Draw.StepsTo solve this, ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
248 Views
Suppose, we have n batteries that can be used a maximum of 5 times. We have some devices that need three batteries and each usage of the device increases the usage count of the batteries by 1. If we have to use the devices k times, we have to find out how many battery combinations we can make to power the devices. A battery cannot be used in two devices simultaneously and a battery that has been used 5 times cannot be included. The usage count of the batteries is given in the array batt.So, if the input is like ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
539 Views
In this problem, we must build C++ code to determine whether or not an array may be divided into two equal subarrays. Also, we have to check the condition if the sum of all the elements in both subarrays is exactly the same or not. The partitioning problem is a variant of the Subset Sum Problem, which is in turn a variant of the Knapsack Problem. We'll use the C++ programming language to tackle the partition problem. We must return a string with a Yes or No depending on whether the specified condition is fulfilled or not.Inputarr[] = {6, 4, ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
2K+ Views
The parallel array is also called the structure array.Definition − A parallel array can be defined as multiple arrays in which the ith elements are closely related, and together, they constitute an entity. An array is a fundamental feature in the C++ language. Making parallel arrays helps us in comparing two or more arrays.For instance, first_name = ['John', 'Dexter', 'Fredd', 'Hank', 'james'] last_name = ['Jocab', 'Jonas', 'smith', 'lee', 'banner'] height = [160, 148, 231, 153, 162]Approach for Making a Parallel ArraySearching and sorting are some of the essential features required to form a parallel array.SearchingSearching is based on specific values ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
411 Views
In this tutorial, we need to solve palindrome substring queries of the given string. Solving palindrome substring queries is far more complex than solving regular queries in C++. It requires a far more complex code and logic.In this tutorial, we are provided string str and Q number of substring[L...R] queries, each with two values L and R. we aim to write a program that will solve Queries to determine whether or not substring[L...R] is a palindrome. We must decide whether or not the substring formed within the range L to R is a palindrome to solve each query. For example ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
384 Views
"Madam" or "racecar" are two words that read the same backward as forwards, called palindromes.If we are given a collection or list of strings, we have to write a C++ code to find out if that can join any two strings in the list together to form a palindrome or not. If any such pair of strings exist in the given list, we have to print "Yes, " else we have to print "No."In this tutorial, input will be an array of strings, and output will be a string value accordingly, for exampleInputlist[] = {"flat", "tea", "chair", "ptalf", "tea"}OutputYesThere is ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
366 Views
In a binary tree, there are only two nodes (left and right) in each child node. Tree structures are simply representations of data. Binary Search Trees (BSTs) are special types of Binary Trees that meet these conditions −Compared to its parent, the left child node is smallerThe parent node of the right child is larger than the child nodeSuppose we're given a binary tree, and we are supposed to find out what's the largest binary search tree (BST) within it.In this task, we will create a function to find the largest BST in a binary tree. When the binary tree ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
3K+ Views
A spanning tree is a linked and undirected graph subgraph that connects all vertices. Many spanning trees can exist in a graph. The minimum spanning tree (MST) on each graph is the same weight or less than all other spanning trees. Weights are assigned to edges of spanning trees and the sum is the weight assigned to each edge. As V is the number of vertices in the graph, the minimum spanning tree has edges of (V - 1), where V is the number of edges.Finding minimum spanning tree using Kruskal’s algorithmAll of the edges should be arranged in a ... Read More
![Prateek Jangid](https://www.tutorialspoint.com/assets/profiles/399467/profile/60_2793348-1637657587.jpeg)
246 Views
In this tutorial, we are given a linked list A of length N and an integer K. We have to reverse alternate pairs of nodes with the size of each pair as K. It is also given that N is divisible by K. First argument is the head pointer of the linked list A and the second argument is an integer K, for exampleInput5 -> 6 -> 2 -> 8 -> 5 -> 2 -> 4 -> 8 -> 9 -> 6 -> null K=2Output6 -> 5 -> 2 -> 8 -> 2 -> 5 -> 4 -> 8 -> ... Read More