Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time to Remove All Cars With Illegal Goods

Try to solve the Minimum Time to Remove All Cars Containing Illegal Goods problem.

Statement

You are given a binary string s representing a train sequence of cars. A character ′1′'1' signifies that the car contains illegal goods, while a character ′0′'0' signifies that it does not.

You need to remove every car containing illegal goods. You may perform any of the following operations:

  • Remove a car from the left end of the sequence, taking 11 unit of time.

  • Remove a car from the right end of the sequence, taking 11 unit of time.

  • Remove a car from any position in the sequence, taking 22 units of time.

Return the minimum total time required to remove all cars containing illegal goods.

Constraints:

  • 1≤1 \leq s.length ≤2×105\leq 2 \times 10^5

  • s[i] is either ′0′'0' or ′1′'1'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time to Remove All Cars With Illegal Goods

Try to solve the Minimum Time to Remove All Cars Containing Illegal Goods problem.

Statement

You are given a binary string s representing a train sequence of cars. A character ′1′'1' signifies that the car contains illegal goods, while a character ′0′'0' signifies that it does not.

You need to remove every car containing illegal goods. You may perform any of the following operations:

  • Remove a car from the left end of the sequence, taking 11 unit of time.

  • Remove a car from the right end of the sequence, taking 11 unit of time.

  • Remove a car from any position in the sequence, taking 22 units of time.

Return the minimum total time required to remove all cars containing illegal goods.

Constraints:

  • 1≤1 \leq s.length ≤2×105\leq 2 \times 10^5

  • s[i] is either ′0′'0' or ′1′'1'.