Graphs

37 problems to practice.

37 Total
5 Easy
16 Medium
16 Hard

Sentence Similarity

1. You will be given two sentences in form of array of string 2. You will also be given a 2d array...

easy

Redundant Connection

1. You are given a 2D-array of edges. Each element of edges is a pair [u, v] with u < v, that repres...

easy

Alien Dictionary

1.Given a sorted dictionary of an alien language having N words and k starting alphabets of standard...

easy

Bellman Ford

You are given 2 integers N and M , N is the number of vertices, M is the number of edges. You'll als...

medium

Negative Weight Cycle Detection

You are given 2 integers N and M , N is the number of vertices, M is the number of edges. You'll als...

hard

Pepcoder And Reversing

You are given 2 integers N and M , N is the number of vertices, M is the number of edges. You'll als...

medium

Pepcoding Course Schedule

Pepcoding offers total of n courses labelled from 0 to n-1. Some courses may have prerequisites....

medium

Kosaraju Algorithm

You are given a graph with N nodes and M directed edges. Find the number of Strongly connected compo...

hard

Mother Vertex

Given a Directed Graph, find a Mother Vertex in the Graph (if present). A Mother Vertex is a verte...

hard

Minimum Cost To Connect All Cities

There are n cities and there are roads in between some of the cities. Somehow all the roads are dama...

medium

Number Of Enclaves

You are given an m * n binary matrix grid, where 0 represents a sea cell and 1 represents a land cel...

medium

Zero One Matrix

Given an m*n binary matrix mat, return the distance of the nearest 0 for each cell. The distance...

medium

Number Of Distinct Island

Given an m*n binary matrix mat, return the number of distinct island. An island is considered to...

medium

Rotting Oranges

You are given an m * n matrix containing 0, 1 or 2 , where 0 represents an empty cell, 1 represents...

easy

As Far From Land As Possible

Given an n*n grid containing only values 0 and 1, where 0 represents water and 1 represents land, fi...

medium

Shortest Bridge

In a given 2D binary array grid, there are two islands. Now, we may change 0s to 1s so as to connect...

easy

Articulation Point

A vertex in an undirected graph is an articluation point iff removing it disconnects the graph. You...

hard

Sliding Puzzle

On an 2 x 3 board, there are five tiles labeled from 1 to 5, and an empty square represented by 0. A...

hard

Bus Routes

You are given an array routes representing bus routes where routes[i] is a bus route that the ith bu...

hard

Optimize Water Distribution

There are n construction sites in a town. We want to supply water for all the construction sites by...

hard

Number Of Island 2

Given an m*n matrix mat, Originally, the 2D matrix is all 0 which means there is only sea in the mat...

hard

Redundant Connection 2

You are given a directed graph that started as a tree with n nodes labeled from 1 to n, with one add...

hard

Kruskal Algorithm

There are n vertices and there are edges in between some of the vertices. Find the sum of edge weig...

medium

Critical Connection

An edge in an undirected graph is a Bridge iff removing it disconnects the graph. You have to print...

medium

Satisfiability Of Equality Equation

You are given an array of strings equations that represent relationships between variables where eac...

medium

Minimum Number Of Swaps Required To Sort An Array

Given an array of n distinct elements, find the minimum number of swaps required to sort the array.

hard

Remove Max Number Of Edges To Keep Graph Fully Traversable

Alice and Bob have an undirected graph of n nodes and 3 types of edges: Type 1: Can be traversed...

hard

Swim In Rising Water

https://leetcode.com/problems/swim-in-rising-water/

hard

Coloring A Border

https://leetcode.com/problems/coloring-a-border/

medium

Regions Cut By Slashes

https://leetcode.com/problems/regions-cut-by-slashes/

hard

Reconstruct Itinerary

https://leetcode.com/problems/reconstruct-itinerary/

medium

Rank Transform Of A Matrix

https://leetcode.com/problems/rank-transform-of-a-matrix/

hard

Minimize Hamming Distance After Swap Operations

https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations/

medium

Accounts Merge

https://leetcode.com/problems/accounts-merge/

medium

Number Of Provinces

https://leetcode.com/problems/number-of-provinces/

medium

Minimize Malware Spread

https://leetcode.com/problems/minimize-malware-spread/

hard

Minimize Malware Spread 2

https://leetcode.com/problems/minimize-malware-spread-ii/

hard