# Tag Archives: union-find

## Check if given intervals can be made non-overlapping by adding/subtracting some X

Given an array arr[] containing N intervals, the task is to check that if the intervals can be added or subtracted by X after which… Read More »

## Find the maximum component size after addition of each edge to the graph

Given an array arr[][] which contains the edges of a graph to be used to construct an undirected graph G with N nodes, the task… Read More »

## Check if one string can be converted to another

Given two strings str and str1, the task is to check whether one string can be converted to other by using the following operation: Convert… Read More »

## Product of minimum edge weight between all pairs of a Tree

Given a tree with N vertices and N-1 Edges. Let’s define a function F(a, b) which is equal to the minimum edge weight in the… Read More »

## Data Structure to Design a special social network

Consider a special social network where people are called connected if one person is connected to other with any number of intermediate connections. For example… Read More »

## Check if the given Binary Expressions are valid

Given n expressions of the type x = y and x != y where 1 ≤ x, y ≤ n, the task is to check… Read More »

## Find the numbers of strings that can be formed after processing Q queries

Given a number N(1<=N<=2000)., The task is to find the number strings of size N that can be obtained after using characters from 'a' to… Read More »

## Minimum changes required to make two arrays identical

Given two arrays and with n elements each. The task is to make these two arrays identical i:e, for each , we want to make… Read More »

## Kruskal’s Algorithm (Simple Implementation for Adjacency Matrix)

Below are the steps for finding MST using Kruskal’s algorithm 1. Sort all the edges in non-decreasing order of their weight. 2. Pick the smallest… Read More »

## Disjoint Set Union on trees | Set 2

Given a tree, and the cost of a subtree is defined as |S|*AND(S) where |S| is the size of the subtree and AND(S) is bitwise… Read More »

## Disjoint Set Union on trees | Set 1

Given a tree and weights of nodes. Weights are non-negative integers. Task is to find maximum size of a subtree of a given tree such… Read More »

## Union-Find Algorithm | (Union By Rank and Find by Optimized Path Compression)

Check whether a given graph contains a cycle or not. Example: Input: Output: Graph contains Cycle. Input: Output: Graph does not contain Cycle. Prerequisites: Disjoint… Read More »

## Calculate number of nodes between two vertices in an acyclic Graph by Disjoint Union method

Given a connected acyclic graph, a source vertex and a destination vertex, your task is to count the number of vertices between the given source… Read More »

## Dynamic Connectivity | Set 1 (Incremental)

Dynamic connectivity is a data structure that dynamically maintains the information about thee connected components of graph. In simple words suppose there is a graph… Read More »

## MakeMyTrip Interview Experience | Set 13 (On-Campus for Full Time)

I recently got interviewed for MakeMyTrip for the Software Engineer full time position. There were in a total of 5 rounds. First Round (Online Coding… Read More »