Skip to content

Latest commit

 

History

History
16 lines (13 loc) · 561 Bytes

File metadata and controls

16 lines (13 loc) · 561 Bytes

Problem 13: Parity Equivalence Span (Replace the Substring for Balanced String)

Problem Statement

You are given a string s of length n containing only 'Q', 'W', 'E', and 'R'. A string is said to be balanced if each of its characters appears n/4 times. Return the minimum length of the substring that can be replaced with any other characters of the same length to make s balanced.

Input Format

  • A string s.

Example

Input: s = "QWER"
Output: 0 Input: s = "QQWE"
Output: 1
Explanation: Replace one 'Q' with 'R'.