Skip to content

Tag Archives: disjoint-set

Given an array arr[](1-based indexing) consisting of N positive integers such that arr[i] denotes the amount of the ith person. Also given are two 2D… Read More
Given an undirected graph G with vertices numbered in the range [0, N] and an array Edges[][] consisting of M edges, the task is to… Read More
Given two arrays A[] and B[] consisting of N positive integers and a matrix List[][] consisting of M pairs of indices, the task is to… Read More
Given a binary matrix mat[][] of dimensions NxM such that 1 denotes the island and 0 denotes the water. The task is to find the… Read More
Prerequisites: DFS, Trees, DSU Given a tree with of N nodes from value 1 to N and E edges and array arr[] which denotes number… Read More
Given an array arr[] consisting of N integers, consisting only of 0‘s initially and queries Q[][] of the form {L, R, C}, the task for… Read More
Given a boolean matrix mat[][] consisting of N rows and M columns, initially filled with 0‘s(empty cells), an integer K and queries Q[][] of the… Read More
Given an undirected graph consisting of N vertices and M edges and queries Q[][] of the type {X, Y}, the task is to check if… Read More
Given a graph consisting of N nodes numbered from 0 to N – 1 and M edges in the form of pairs {a, b}, the… Read More
In this article, we will generate test cases such that given set edges form a Tree. Below are the two conditions of the Tree: It… Read More
Given Two Strings s1 and s2 containing only lowercase letters of same length. The task is to make these strings equal by using the minimum… Read More
Given N nodes on a 2-D plane represented as (xi, yi). The nodes are said to be connected if the manhattan distance between them is… Read More
Given a graph with N nodes having values either P or M. Also given K pairs of integers as (x, y) representing the edges in… Read More