Shubham Vora has Published 962 Articles

Restore a Shuffled Queue as Per given Conditions

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:55:29

61 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 ... Read More

Minimum Nodes to be Colored in a Graph such that every Node has a Colored Neighbour

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:53:47

62 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 ... Read More

Minimum Distance from a given Cell to all other Cells of a Matrix

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:51:23

122 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 ... Read More

Minimum Cost using Dijkstra by Modifying Cost of an Edge

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:49:54

213 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 ... Read More

Maximum Possible Array Sum after Performing given Operations

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:47:10

397 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, ... Read More

Maximum Absolute difference between any two Level Sum in a Binary Tree

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:44:36

103 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 ... Read More

Maximize Shortest Path between given Vertices by Adding a Single Edge

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:42:20

115 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 ... Read More

Longest Subarray whose Elements can be Made Equal by Maximum K Increments

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:40:21

281 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 ... Read More

Implementation of a Hypergraph

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:38:36

148 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 ... Read More

Count of Array Elements whose Order of Deletion Precedes Order of Insertion

Shubham Vora

Shubham Vora

Updated on 02-Aug-2023 13:36:59

54 Views

In this problem, we will count the number of elements removed from the array before they are inserted in the array. The logical part for solving the problem is that check for all numbers that its position in the remove[] array before its position in the insert[] array. If yes, ... Read More

Advertisements