FastPrepMaximize Consecutive Equal Answers
Problems/Maximize Consecutive Equal Answers

Maximize Consecutive Equal Answers

Amazon logoAmazon● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported task identifies this algorithmic exercise. The executable interface, bounds, deterministic tie rules, and examples are the documented practice contract.

A string contains only T and F. You may change at most maxChanges characters. Return the maximum length of a contiguous substring that can be made entirely equal.

Function

maximizeConfusion(answers: String, maxChanges: int) → int

Examples

Example 1

answers = "TTFF"maxChanges = 2return = 4

Case 1 exercises the documented deterministic contract.

Example 2

answers = "TFFT"maxChanges = 1return = 3

Case 2 exercises the documented deterministic contract.

Example 3

answers = "TTFTTFTT"maxChanges = 1return = 5

Case 3 exercises the documented deterministic contract.

Constraints

  • 1 <= answers.length <= 200000.
  • 0 <= maxChanges <= answers.length.

More Amazon problems

  • Count Adjacent Symbol Pairs for BPEONSITE INTERVIEW · Seen Nov 2026
  • First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
See Amazon hiring insights
Saved
class Solution {
    public int maximizeConfusion(String answers, int maxChanges) {
        // Write your code here.
    }

}
Checking account…