Here i am gonna cover coding problem which was asked in Google kick start competition 2021 in Round A, Let' Begin.
Problem
Charles defines the goodness score of a string as the number of indices such that where (-indexed). For example, the string CABABC
has a goodness score of since and .
Charles gave Ada a string of length , consisting of uppercase letters and asked her to convert it into a string with a goodness score of . In one operation, Ada can change any character in the string to any uppercase letter. Could you help Ada find the minimum number of operations required to transform the given string into a string with goodness score equal to ?
Input
The first line of the input gives the number of test cases, . test cases follow.
The first line of each test case contains two integers and . The second line of each test case contains a string of length , consisting of uppercase letters.
Output
For each test case, output one line containing Case #:
, where is the test case number (starting from 1) and is the minimum number of operations required to transform the given string into a string with goodness score equal to .
Limits
Memory limit: 1 GB.
.
Test Set 1
Time limit: 20 seconds.
.
Test Set 2
Time limit: 40 seconds.
for at most test cases.
For the remaining cases, .
Let's Code then,
C++:
Python3:
Thank You 😊😊
Comments
Post a Comment