Microsoft Online Assessment
Anonymous User
918

Write a program where a board is made of 2 rows and n columns. The board is represented by 2 strings row1 and row2, made of characters "R", "W" and/or "?" . A board is balanced if each row and column has equal no of R and W. The question marks can be replaced with W or R to make the board balanced. Return the minimum no of replacements to make the board balanced if not possible to balance return -1.

Example:

row1="W?WR?" and row2="R??W?" ans is 3
row1="RR?" and row2="?R?" ans is -1
row1="R?R??" and row2="??W??" ans is 5

Comments (3)