InterviewDB Question

Largest Shape: Find the Largest Connected Region of the Same Value in a 2D Grid

Question Details

Round 1 - Coding Problem Given an M x N grid of integers, find the largest connected region where all cells share the same value. Connectivity is 4-directional (up, down, left, right). Return the size and value of that region. Example Approach BFS/DFS from each unvisited cell, tracking region size and value. Keep a visited set to avoid double-counting. Follow-ups How does your solution change if you also allow diagonal connectivity (8-directional)? If the grid is very large (10,000 x 10,000), ho…

Full Details

🔒

Unlock all Glean questions

Full insider details, leaked discussions, and candidate experiences.

Get full access — $100 a year, unlimited access

About This Question

This is a reported interview question from a glean interview during the phone round.

It covers the following topics: Phone, Graph, Coding, Onsite, Matrix .