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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Eric Redmond ,Jim Wilson

1st Edition

1934356921, 978-1934356920

More Books

Students also viewed these Databases questions

Question

i need to extend my rental return

Answered: 1 week ago