← Samsung questions
CodingMedium

Detect cycle in a graph

Filed under Samsung · Also reported at BNY Mellon, Paytm

Given a directed graph represented as an adjacency list, implement an algorithm to detect if the graph contains any cycles. A cycle exists if there is a path that starts and ends at the same node.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Samsung questions

Collected from public candidate posts and coding forums. Updated Nov 2026.