RANDG - Red And Green
Red & Green
You have several squares arranged in a single row. Each square is currently painted red or green. You can choose any of the squares and paint it over with either color. The goal is that, after painting, every red square is further to the left than any of the green squares. We want you to do it repainting the minimum possible number of squares.
Squares are numbered from left to right. You will be given the initial arrangement as a String, such that character i is 'R' if square i is red or 'G' if square i is green. Print the minimum number of repaints needed to achieve the goal.
There will be several test cases. Each test case will contain a string of not more than 50 characters on a separate line. Input is terminated by EOF.
For each test case, print the output on a separate line.
-Input will contain between 1 and 50 characters, inclusive.
-Each character of input will be either 'R' or 'G'.
Solution & Dataset : Bidhan Roy
strings could have been longer, the most naive brute-force solution gets AC in 0.00 :/
got AC 0.00 sec but not content with that still looking forward to new logic....
Nirmal: you should repaint all red squares, so you will get GGGGGGG.
i could't understand third test case.. someone help me .. GGGGRRR
@Roy ... can you check my submission and hint me where am i going wrong.. Id:9370526Last edit: 2013-05-29 03:51:51