← Amazon questions

Length of largest region in a matrix and cycle detection

Filed under Amazon

Given a 2D matrix, find the length of the largest connected region of 1s (connected horizontally, vertically, or diagonally). Additionally, write an algorithm to detect a cycle in an undirected graph.

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 Amazon questions

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