Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 2 Java 8 There is a board made of two rows and N columns. The board is represented by two strings, row 1 and

Task 2
Java 8
There is a board made of two rows and N columns. The board is represented by two strings, row1 and row2, made of characters 'R','W' and/or '?'. A board is balanced if, in each row and in each column, the number of characters 'R' is equal to the number of characters 'W'. For example, the following board is balanced:
?RW?WR
?WR?RW
and the following board is not balanced:
W?WR?
R??W?
(there are two characters 'W' and one character 'R' in the first row).
The question marks ('?') can be replaced with 'W' or 'R'. What is the minimum number of replacements needed to balance the board?
Write a function:
class Solution { public int solution(String row1, String row2) ; }
that, given two strings row1 and row2 made of N characters each, returns the minimum number of replacements needed to balance the board. If it is not possible to balance the board, the function should return -1.
14C
Partly sunny
Search
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

explain what is meant by experiential learning

Answered: 1 week ago

Question

3. What may be the goal of the team?

Answered: 1 week ago

Question

Is how things are said consistent with what is said?

Answered: 1 week ago

Question

Has the priority order been provided by someone else?

Answered: 1 week ago