FastPrepFind Largest House Area
Problems/Find Largest House Area

Find Largest House Area

HSBC logoHSBC● EasyOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Corrected on 2026-07-19. The placeholder constraint has been replaced with the binary grid rule shown in the source. The judged task matches the visible source at about 99%.

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[][]) → int

Examples

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 = 3
grid
01234000000101100200000300110400100

The area of the biggest house is 3. So, the output is 3.

Constraints

  • Every grid cell is either 0 or 1.

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
All HSBC interview questionsSee HSBC hiring insights
Saved
class Solution {
    public int findLargestHouseArea(int[][] grid) {
      // write your code here
    }

}
Checking account…