- Alien Dictionary
Given a sorted dictionary of an alien language having N words and k starting alphabets of standard dictionary. Find the
- BFS
Only read the BFS part if in hurry.
- Bellman Ford
if distance[u] + w < distance[v], update distance[v] = distance[u] + w.
- Count the number of complete components
You are given an integer n. There is an undirected graph with n vertices, numbered from 0 to n - 1. You are given a 2D i
- Course Schedule
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prere
- Detect Cycle in a graph
Breadth-First Search (BFS) explores nodes level by level. If a neighbor is encountered that has already been visited and
- DisJoint Set
static class DisjointSet {
- Find Eventual Safe States
There is a directed graph of n nodes with each node labeled from 0 to n - 1. The graph is represented by a 0-indexed 2D
- Floyd Warshall
solving all-pairs shortest path problems, and detecting negative cycles in graphs.
- Minimum Height Trees
A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected
- Minimum cost to connect all points
You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].
- Network Delay
You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed ed
- Number Of Provinces
There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and cit
- Number of operations to make a network connected
There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connecti
- Prims Algorithm (Greedy Algorithm)
Run this to see how PRIMS algorithm find MST.
- Rotten Oranges
You are given an m x n grid where each cell can have one of three values:
- Topological Sort
When to use Topological Sort:
- is Graph Bipartite
There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array gra