You are given an integer array forts of length n representing the state of forts along a line:
forts[i] = i is empty.
forts[i] = i contains an enemy fort.
forts[i] = i contains a fort under your command.
You want to move your army from a fort under your command at position i to an empty fort at position j such that every position strictly between i and j contains an enemy fort. That is, for every index k where forts[k] =
All enemy forts between i and j are captured during this movement.
Return the maximum number of enemy forts that can be captured. If no movement is possible, return
Constraints:
forts.length
forts[i]
You are given an integer array forts of length n representing the state of forts along a line:
forts[i] = i is empty.
forts[i] = i contains an enemy fort.
forts[i] = i contains a fort under your command.
You want to move your army from a fort under your command at position i to an empty fort at position j such that every position strictly between i and j contains an enemy fort. That is, for every index k where forts[k] =
All enemy forts between i and j are captured during this movement.
Return the maximum number of enemy forts that can be captured. If no movement is possible, return
Constraints:
forts.length
forts[i]