![]() ![]() Call the findMinStep() with two strings to get the answer.for initialize i := 0, j := 0, when j = 3, then −. ![]() Define a function solve(), this will take s, an array v,.for initialize i := 0, when i = if INF is non zero then check with - 1 otherwise with ret.Define a function findMinStep(), this will take s, hand,.To solve this, we will follow these steps − ![]() We can add R after RR, (WRRBBW), after removal, the sequence will be (WBBW), then add B, so (WBBW), after removal it will be (WW), then add W, so the sequence will be (WW). So if the input is like “WRRBBW”, and we have “RBW”, then the answer will be 3. If we cannot remove all the balls, then return -1. We have to find the minimal balls we have to insert to remove all the balls on the table. Keep doing this until no more balls can be removed. Then, if there is a group of 3 or more balls in the same color touching, remove them. Now, each time, we may choose a ball from our side, and insert it into the row. Suppose we have a row of balls on the table, these balls are colored as red(R), yellow(Y), blue(B), green(G), and white(W). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |