Shubham Vora has Published 793 Articles

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

343 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

423 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

890 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

255 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

267 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

486 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

385 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

149 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

Find the Largest Multiple of 3 (Using Queue)

Shubham Vora

Shubham Vora

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

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

Find the K Closest Points to Origin using Priority Queue

Shubham Vora

Shubham Vora

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

311 Views

In this problem, we will find the K nearest point from the origin in the 2D plane from the given N points. We can use the standard Euclidean distance formula to calculate the distance between the origin and each given point. After that, we can store the points with distance ... Read More

Advertisements