Round 1
Questions: A sorcerer has discovered a magical sequence of runes, represented as a string made up of two types of runes: X and Y. The sorcerer wants to maximize their magical power by transforming the sequence into more potent forms. The sorcerer can perform two types of transformations:
- Pick a substring XY, transform it into YZ, and gain one unit of magical power.
- Pick a substring YX, transform it into ZY, and gain one unit of magical power.
Your task is to find out the maximum magical power the sorcerer can accumulate by performing these transformations.
Input:
- The first & only line contains the string's (1 ≤ |s| ≤ 200,000). All characters of s are either X or Y.
Output:
- Output a single integer the maximum magical power (number of transformations) the sorcerer can obtain.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.