**Introduction**

Professor Reddy is a Physics teacher. He will be organizing a physics test that will contain True/False questions. Each question has an answer which is either true or false. He wants to design the question paper to maximize the confusion for the students. One way he can do this is to keep a series of questions whose answer is True, then keep a series of questions whose answer is False, and so on. Thus he can create confusion among the students. Let us now discuss the problem statement and the possible solution.

Recommended topic, __kth largest element in an array__, and __Euclid GCD Algorithm__

**Problem Statement**

A teacher is creating an exam containing N true/false questions, with the letters 'T' indicating true and 'F' indicating false. He intends to confuse the students by increasing the amount of questions with the same answer in a succession (multiple trues or multiple falses in a row). You're given a string answerKey, where answerKey[i] is the ith question's original answer. You're also provided an integer k, which represents the maximum number of times you can conduct the following operation: Set any question's answer key to 'T' or 'F' (i.e., set answerKey[i] to 'T' or 'F'). After completing the operation k times, return the maximum number of consecutive 'T's or 'F's in the answer key.

**Example 1**

answerKey=”TTFF”, K = 2.

We can toggle the last two ‘F’ to ‘T’ as K = 2. So we can do the operation two times at max. Thus final string will be “TTTT”. Thus there are four consecutive ‘T’ in a row.

**Output: **4

**Example 2**

answerKey=”TTFTTFTT”, k=1.

We can toggle ‘F’ at index 2, or we can toggle ‘F’ at index ‘5’. Thus the modifies ‘answerKey’ will be “TTTTTFTT” or “TTFTTTTT”. In both cases, we have 5 consecutive ‘T’. Therefore the output is 4.

**Output**: 5