Hi code in Java thank you. You are mapping a faraway planet using a satellite. The planet’s surface can be modeled as a grid. The satellite has captured an image of the surface. Each grid square is either land (denoted as ‘L’), water (denoted as ‘W’), or covered by clouds (denoted as ‘C’). Clouds mean that the surface could either be land or water; you cannot tell.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hi code in Java thank you.

You are mapping a faraway planet using a satellite. The planet’s surface can be modeled as a grid. The satellite has captured an image of the surface. Each grid square is either land (denoted as ‘L’), water (denoted as ‘W’), or covered by clouds (denoted as ‘C’). Clouds mean that the surface could either be land or water; you cannot tell.

Sample Input 2
32
LW
Сс
WL
Sample Output 2
1
Ľ
Transcribed Image Text:Sample Input 2 32 LW Сс WL Sample Output 2 1 Ľ
You are mapping a faraway planet using a satellite. The planet's surface can be
modeled as a grid. The satellite has captured an image of the surface. Each grid
square is either land (denoted as 'L'), water (denoted as 'w'), or covered by clouds
(denoted as 'c'). Clouds mean that the surface could either be land or water; you
cannot tell.
An island is a region of land where every grid cell in the island is connected to
every other by some path, and every leg of the path only goes up, down, left or
right.
Given an image, determine the minimum number of islands that is consistent
with the given image.
Input
Each input will consist of a single test case. Note that your program may be run
multiple times on different inputs. The first line of input contains two integers, r
and c (1 ≤r, c < 50), which are the number of rows and the number of columns
of the image. The next r lines will each contain exactly c characters, consisting
only of 'L' (representing Land), 'w' (representing Water), and 'c' (representing
Clouds).
Output
Output a single integer, which is the minimum number of islands possible.
Sample Input 1
Sample Output 1
45
ссссс
CCCCC
CCCCC
ccccc
0
Transcribed Image Text:You are mapping a faraway planet using a satellite. The planet's surface can be modeled as a grid. The satellite has captured an image of the surface. Each grid square is either land (denoted as 'L'), water (denoted as 'w'), or covered by clouds (denoted as 'c'). Clouds mean that the surface could either be land or water; you cannot tell. An island is a region of land where every grid cell in the island is connected to every other by some path, and every leg of the path only goes up, down, left or right. Given an image, determine the minimum number of islands that is consistent with the given image. Input Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. The first line of input contains two integers, r and c (1 ≤r, c < 50), which are the number of rows and the number of columns of the image. The next r lines will each contain exactly c characters, consisting only of 'L' (representing Land), 'w' (representing Water), and 'c' (representing Clouds). Output Output a single integer, which is the minimum number of islands possible. Sample Input 1 Sample Output 1 45 ссссс CCCCC CCCCC ccccc 0
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Managing System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education