Find Largest House Area
Updated
Problem statement
A residential area is represented by an N by M grid. A cell containing part of a house roof has value 1, while a vacant plot has value 0.
A house is a cluster of cells with value 1 connected horizontally or vertically. Diagonal contact does not connect two cells into the same house. The area of a house is the number of cells it contains.
Return the area of the largest house.
Function
findLargestHouseArea(grid: int[][]) → intExamples
Example 1
grid = [[0, 0, 0, 0, 0], [0, 1, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 0, 0]]return = 3The area of the biggest house is 3. So, the output is 3.
Constraints
- Every grid cell is either
0or1.
More HSBC interview questions
- Organization Reputation After Employee DeparturesOA · Seen Nov 2026
- Remove Vowels from a StringOA · Seen Nov 2026
- Minimum Deletion Cost for Distinct Adjacent CharactersOA · Seen Oct 2026
- Maximum 69 NumberONSITE INTERVIEW · Seen Oct 2026
- Second Distinct Largest ElementONSITE INTERVIEW · Seen Oct 2026
- Distinct Products After Removing One ElementOA · Seen Sep 2026
- Minimum Cleaning Robot RunsOA · Seen Sep 2026
- Minimum Satellite Data Transfer IterationsOA · Seen Aug 2026
- Find ID of SoldierOA · Seen Jun 2026
- Find Most Frequently Purchased ProductsOA · Seen Jun 2026
Similar questions at other companies
- Connected GroupsVisa · OAVisa interview questions
- Replacing Val 🍓Two Sigma · OATwo Sigma interview questions
- Count Connected Equal TilesIntuit · OAIntuit interview questions
- Count Battleships by SizeDeloitte · OADeloitte interview questions
- Word SearchBloomberg LP · OA · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Number of IslandsGoldman Sachs · OA · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
- House Bounds in a Ragged GridRippling · OA · PHONE SCREENRippling interview questions
- Increasing Paths, part 1Hudson River Trading · OAHudson River Trading interview questions
- Cave AdvantureMeta · OAMeta interview questions
- Maximum Damage PatchGecko Robotics · OA · PHONE SCREEN