Question: Give solution for this in php - - - - There are n buckets arranged in a row. each bucket either is empty or contains

Give solution for this in php ---- There are n buckets arranged in a row. each bucket either is empty or contains a ball. the buckets are specified as a string buckets consisting of characters '.' and 'B' in one move you can take the ball out of any bucket and place it in another empty bucket. your goal is to arrange the balls to create an alternating sequence of full and empty buckets. distance between two consecutive balls should be equal to 2, note that the sequence may start at any bucket we need to give what is minimum numbers of moves required to create a correct sequence of balls in bucket. If it is impossible return -1.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!