Posts with tag 'graph'

Separate People Given Dislike Relations

1 minute read

You are given an integer n and a two-dimensional list of integers enemies. Integer n means there’s n people labeled from [0, n - 1]. Each element in enemies ...

String Equivalence Relations

1 minute read

You are given three lowercase alphabet strings a, b and target. Strings a and b have the same length and are defined to be equivalent: a[i] = b[i]. For examp...

Shortest Bridge

1 minute read

Given a two-dimensional list of integers matrix containing 0s and 1s, 0 represents water and 1 represents land.

Detecting an Odd Length Cycle

less than 1 minute read

Given an undirected graph as an adjacency list, return whether the graph has an odd length cycle.

Bipartite Graph

1 minute read

Given an undirected graph represented as an adjacency list, return whether the graph is bipartite.

Shipping and Receiving

1 minute read

You are given a two-dimensional list of integers ports where ports[i] represents the list of ports that port i is connected to. You are also given another tw...

Sinking Islands

1 minute read

Given an 2D matrix of 0s and 1s, a 1 represents land and 0 represents water. An island is a group of 1’s that are surrounded by 0s or by the border. Find all...

Paint Bucket

1 minute read

You are given a two dimensional array matrix, containing strings “r”, “g”, and “b”. Perform a floodfill operation at row r, column c with the color target.

Minimum Starting Nodes to Visit Graph

less than 1 minute read

You are given a two-dimensional list of integers edges representing a connected, directed, acyclic graph. Each element in edges contains [u, v] meaning there...

Island Shape Perimeter

less than 1 minute read

Given a two-dimensional integer matrix of 1s and 0s where 0 represents empty cell and 1 represents a block that forms a shape, return the perimeter of the sh...

Reverse Graph

1 minute read

Given a directed graph represented as an adjacency list, return its reverse so if an edge goes from A to B, it now goes from B to A.

Number of Islands

1 minute read

Given a two-dimensional integer matrix of 1s and 0s, return the number of “islands” in the matrix. A 1 represents land and 0 represents water, so an island i...

Largest Island Area

1 minute read

You are given a two-dimensional integer matrix of 1s and 0s. A 1 represents land and 0 represents water, so an island is a group of 1s that are neighboring w...

No New Friends

1 minute read

You are given n people represented as an integer from 0 to n - 1, and a list of friends tuples, where person friends[i][0] and person friends[i][1] are frien...

Friend Groups

less than 1 minute read

You are given an undirected graph friends as an adjacency list, where friends[i] is a list of people i is friends with. Friendships are two-way. Two people a...

Flight Itinerary

1 minute read

You are given a list of flights that were taken, represented as origin to destination airport pairs. Given that this list was shuffled, find all the airports...

Mutual Followers

less than 1 minute read

You are given a two-dimensional list of integers relations. Each element relations[i] contains [a, b] meaning that person a is following person b on Twitter.

Back to top ↑