All Posts

Leetcode 684: Redundant Connection

You are given a graph that started as a tree with n nodes. One additional edge has been added, creating a cycle. Your task is to find and return the redundant edge that, when removed, would turn the graph back into a tree.

Leetcode 743: Network Delay Time

You are given a network of n nodes and a list of directed edges with travel times. You need to send a signal from a given node k. Return the minimum time it takes for all nodes to receive the signal, or return -1 if it is impossible.

Leetcode 785: Is Graph Bipartite?

You are given an undirected graph where each node is labeled between 0 and n - 1. The graph is represented as a 2D array, where graph[u] contains the nodes that are adjacent to node u. A graph is bipartite if its nodes can be divided into two sets such that every edge connects a node from one set to a node in the other set. Your task is to return true if the graph is bipartite, otherwise return false.

Leetcode 787: Cheapest Flights Within K Stops

You are given a number of cities and a list of flights between them. Each flight has a price and connects two cities. You need to find the cheapest route from a given source city to a destination city with at most a certain number of stops. If no such route exists, return -1.

Leetcode 797: All Paths From Source to Target

You are given a directed acyclic graph (DAG) with n nodes, labeled from 0 to n-1. Find all possible paths from node 0 to node n-1 and return these paths in any order. The graph is represented such that each node has a list of other nodes that can be visited directly from it.

Leetcode 802: Find Eventual Safe States

You are given a directed graph where each node represents a point, and edges represent possible transitions between nodes. A node is considered terminal if it has no outgoing edges. A node is deemed safe if every path starting from it leads either to a terminal node or another safe node. Your task is to identify all the safe nodes in the graph and return them in ascending order.