leetle

Daily challenge for 2026-08-31

608. Vertices with Self Loops

You are given an integer n representing the number of vertices (labeled 0 to n - 1) in a graph, and a list of edges where each edge is represented as a pair of vertices [u, v]. A self-loop is defined as an edge that starts and ends at the same vertex (i.e., u == v).

Return a sorted list of all unique vertices that have at least one self-loop.

Example:
Input: n = 4, edges = [[0, 0], [1, 2], [2, 2], [3, 0]]
Output: [0, 2]

Run this challenge interactively in Python or JavaScript when the app loads.