Skip to main content

9 docs tagged with "Graph"

View All Tags

Bus Routes

Return the least number of buses you must take to travel from source to target. Return -1 if it is not possible.

Cheapest Flights Within K Stops

You are also given three integers src, dst, and k, return the cheapest price from src to dst with at most k stops. If there is no such route, return -1.

Course Schedule

For example, the pair [0, 1], indicates that to take course 0 you have to first take course 1. Return true if you can finish all courses. Otherwise, return false.

Course Schedule II

Return the ordering of courses you should take to finish all courses. If there are many valid answers, return any of them. If it is impossible to finish all courses, return an empty array.

Minimum Height Trees

Among all possible rooted trees, those with minimum height (i.e. min(h)) are called minimum height trees (MHTs).

Number of Islands

Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.

Pacific Atlantic Water Flow

There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the Atlantic Ocean touches the island's right and bottom edges.