Company: Factset_9oct
Difficulty: medium
Maximize Equalized Substrings After One Swap Problem Description You are given an equalized string, where the number of 'L' characters is the same as the number of 'R' characters. Determine the maximum number of equalized substrings into which the string can be divided, after performing at most one swap of two adjacent characters. Note: An equalized substring is any contiguous part of the string in which the total number of 'L' characters equals the total number of 'R' characters. Return an integer representing this maximum count. Examples Example 1: Input: s = "RLRLLRLRL" Output: 5 Explanation: Swapping the characters at indices 3 and 4 (0-based) changes the string to "RLRLRLRLRL". This updated string can be divided into: "RL", "RL", "RL", "RL", and "RL", each of which is an equalized substring. Hence, the answer is 5. Example 2: Input: s = "LLLLRRRR" Output: 1 Explanation: No single swap can increase the count of equalized substrings, so the entire string forms just one equalized sub