Company: Toast_27april
Difficulty: medium
Binary String Game Problem Alice starts with a binary string B of length 3 n and repeats the following operation until a single character is left: Split the current string into contiguous groups of exactly 3 characters, taking them left to right. Replace each group by the character that occurs most often inside that group, keeping the groups in their original order. Formally, if the current string is B = B[1] B[2] ... B[L] with L = 3 k , one operation produces the string C = C[1] C[2] ... C[L/3] , where C[i] is the character that appears most often among B[3i-2] , B[3i-1] and B[3i] . The length therefore shrinks from 3 n to 3 n-1 , then to 3 n-2 , and so on, so exactly n operations are performed and one character remains at the end. You are given the integer n and a target character fin . Count the binary strings B of length 3 n whose last remaining character is fin , and print that count modulo 1000000007. Function Description Complete the function solve(n, fin) . n (int): the startin