Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Find the area of the largest house Question The current selected programming language is Java. We emphasize the submission of a fully working code over
Find the area of the largest house
Question The current selected programming language is Java. We emphasize the submission of a fully working code over partially correct but efficient code. Once submitted, you cannot review this problem again. You can use System.out.println() to debug your code. The 1 import java.uti 2 import java.lang 34567 3 import java.io.* 5 /* * grid represen */ public class Sol 8 9 { 10 public stati System.out.println() may not work in 11 { case of syntax/runtime error. The version of JDK being used is 1.8. 12 int ans 13 // Write 14 Note: The main class name must be "Solution". 15 16 return ar 17 } 18 The city authorities conduct a study of the houses in a residential area for a city planning scheme. The area is depicted in an aerial view and divided into an N x M grid. If a grid cell contains some part of a house roof, then it is assigned the value 1; otherwise, the cell represents a vacant plot and is assigned the value 0. Clusters of adjacent grid cells with value 1 represent a single house. Diagonally placed grids with value 1 do not represent a single house. The area of a house is the number of 1s that it spans. 19 public static 20 { 21 Scanner i 22 // input 23 int grid_ 24 int grid_ 25 int grid[] 26 for (int i 27 { 28 for(in 29 { 30 gr 31 } 32 } 33 Write an algorithm to find the area of the largest house. 34 int result Input 9 APR 6,949 12
Step by Step Solution
There are 3 Steps involved in it
Step: 1
find the area of the largest house in the grid you can use a depthfirst search DFS algorithm to trav...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started