Practice Maximum Enemy Forts That Can Be Captured
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
forts uses 1 for a fort you command, 0 for an enemy fort and -1 for an empty position. Move from one of your forts to an empty position only when every position strictly between them is an enemy fort. All intervening enemy forts are captured. Return the greatest number captured by one such move, or 0 if no capture is possible.
Source: Maximum Enemy Forts That Can Be Captured on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
forts = [1,0,0,-1,0,0,0,0,1]
4
# Example 2
forts = [0,0,1,-1]
0
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Enemy Forts That Can Be Captured.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.