Practice Minimum Time to Remove All Cars Containing Illegal Goods
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Minimum Time to Remove All Cars Containing Illegal Goods
Problem Statement
Binary s describes train cars; 1 marks illegal goods and 0 marks an empty car. Remove a car from either end for one unit of time, or from any position for two units. Repeat as needed, including removing cars without illegal goods. Return the least total time to remove every 1; an empty train is allowed.
Source: Minimum Time to Remove All Cars Containing Illegal Goods on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "1100101"
5
# Example 2
s = "0010"
2
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Time to Remove All Cars Containing Illegal Goods.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.