Akbar's Army
Q.
Akbar has an amry of size n consisting of both footmen and horsemen. He loves to line up his soilders. Akbar feels that the power of his army is the maximum number of consecutive soilders of the same type - footmen or horsemen. He has k reserve horsemen and footmen each. Any soilder in the existing lineup can be replaced by one from the reserve. As the commander-in-chief of his army, Akbar has asked you to arrange his amry so that it has the greatest power.
You are given a string army consisting of a and b where -: Footmen are represented by a and horsemen are represented by b.
You have to return the maximum power of army that can be achieved.
Example 1:
Input: n = 8, k = 1, army = "aabaabaa"
Output: 5
Explanation: Replace one horsemen with one footman from reserve to get power of five consecutive footmen.
Example 2:
Input: n = 4, k = 2, army = "abba"
Output: 4
Explanation: Replace two horsemen with two footmen or two footmen with two horsemen from reserve.
Here is my code
https://leetcode.com/playground/XpaLvGdR
The other question was quite easy , related to tree level order.