I am working on LeetCode problem 827. Making A Large Island: You are given an n x n binary matrix grid. You are allowed to change at most one 0 to be 1. Return the size of the largest island in grid after applying this operation. An island is a 4-directionally connected group of 1s. Example 1: Input: grid =

# Tag: graph

## Experimental Analysis of an Algorithm – How to prove that the graph is O(nlogn)?

This question is probably stupid, but I’ve been trying to figure this out for hours and I still couldn’t find anything about it. Probably I’m just too lost. So basically, I’m analysing an algorithm by …

## Add new edge to Graph and check if total weight is reduced

I’m new to Graphs and I’m trying to solve this problem in Java: Given a Graph with N nodes and N-1 weighted bidirectional edges, the algorithm must respond YES if a new edge ‘q’ allows to reduce the …

## Array out of bound exception while doing topological sort

This code takes the no. of nodes in a graph and creates the graph with the number of nodes and then the user has to input the one-way edges between two vertices.(The formed Graph is a Directed Acyclic …

## Merge sets when two elements in common

This is the follow up of compare sets I have I want to merge the sets when there are two elements in common. For example 0,1,2 and 0,2,6 has two elements in common so merging them to form [0,1,2,6]. Again [0,1,2,6] and [2,6,7] has 2 and 6 common. so merging them and getting [0,1,2,6,7]. The final output should be :