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

138 Views
In this problem, we have given the persona names and the number of taller people standing in front of that people. We can sort the position of the people according to the number of taller people standing in front of any person. After that, we update the position of each person according to the nums[] array value to get the original queue. Problem statement − We have given an array persons[] and nums[]. The persons[] array contains the person's name, and the nums[] array contains the number of taller people standing in front of each person. This queue is shuffled, ... Read More

160 Views
In this problem, we will color the minimum nodes of the graph such that each node of the graph has a colored node at the maximum distance 1. The simple logic to minimize the count of the colored node is that either color the nodes which are at an odd distance or color the nodes at an even distance. So, we can color the alternative node, and for each node, we can have a colored node at most distance 1. Problem statement − We have given a graph containing N nodes and E edges. It is given that we can ... Read More

254 Views
In this problem, we need to find the distance of each cell from the given cell of the matrix. We will use the Breadth−first search traversal to visit each cell of the matrix from the given cell and find the minimum distance for each cell. Problem statement − We have given rows, cols, a, and b positive integers. Here, rows and cols represent the matrix's total number of rows and columns. The a and b is the cell of the matrix. We need to find the minimum distance of each cell of the matrix from the (a, b) cell. ... Read More

354 Views
In this problem, we need to find the minimum path from 1 to N using Dijakstra’s algorithm, and we can update the cost of any single edge to cost/2. Here, we will find each node's distance from the source node to the destination node. After that, we will take the shortest distance of node u from the source and node v from the destination and add them with the cost/2 of the u −> v edge. In this way, we will find the minimum cost of path 1 to N. Problem statement − We have given an undirected graph ... Read More

593 Views
In this problem, we will perform the given operations on the array elements and find the maximum sum at last. Here, in each operation, we can select at most X[p] elements from the array and replace them with the Y[p] elements to maximize the sum. In the naïve approach, we will find X[p] array elements, which are smaller than the Y[p] elements, and replace them with Y[p]. In the efficient approach, we will use the priority queue to get the maximum sum. Problem statement − We have given nums[] array containing the N numbers. Also, we have given ... Read More

190 Views
In this problem, we will find the maximum absolute difference between the sum of all nodes of any two levels. We can use the queue data structure to traverse through each binary tree level. While traversing each level, we can keep track of the maximum and minimum sum and return the absolute difference at last. Problem statement − We have given a binary tree containing the positive and negative integer values. We need to find the maximum absolute difference of the sum of all nodes of any two levels. Sample examples Input ... Read More

219 Views
In this problem, we will maximize the shortest path between the vertex 1 to N by adding the edge between two selected vertices. Here, we will track the distance of each node of the graph from the 0th and N − 1 nodes. After that, we will insert the single edge between any two selected vertices in such a way that we can maximize the shortest path between 1 to N. Problem statement − We have given an undirected graph. The graph contains the N vertices and M edges. Also, we have given the s_edges[] array containing the K−selected ... Read More

442 Views
In this problem, we will find the length of the longest subarray so that we can make all subarray elements the same by adding some positive integer values, and the sum of added numbers to each element shouldn’t increase than K. The naïve approach is to find the cost of making all elements the same in each subarray of the given array. Finally, consider the length of the subarray whose cost is less than K and the length is maximum. However, we will use the queue data structure to solve the problem efficiently. Problem statement − We have given an ... Read More

308 Views
In this tutorial, we will learn to implement the hypergraph in C++. Definition − The hypergraph is a special version of the graph. In which the single can connect 2 or more vertices. In a normal graph, the single edge can connect only 2 vertices, but a hypergraph is a generalization of the graph and can be used to connect more than 2 vertices with the single edge. In the hypergraph, the edge is called the hyperedge. We can represent the hypergraph with H(E, V), where E is a hyperedge and v is the set of vertices connected by the ... Read More

155 Views
In this problem, we will find the largest multiple of 3 using the array elements. The naïve approach is that generate all possible combinations of array elements and check whether it is divisible by 3. In this way, keep track of the maximum possible multiple of 3. The efficient approach is using three queues. We can use queues to store elements based on the remainder after dividing it into 3. After that, we can remove some elements from the queue to make a multiple of 3 from the remaining array elements. Problem statement − We have given an array ... Read More