Tap here to switch tabs
Problem
Submissions

Problem: Minimum Amount of Time to Collect Garbage

med
30 min
Try to solve the Minimum Amount of Time to Collect Garbage problem.

Statement

You are given a 00 indexed array of strings garbage, where garbage[i] represents the assortment of garbage at the iextthi^{ ext{th}} house. Each character in garbage[i] represents one unit of garbage: 'M' for metal, 'P' for paper, and 'G' for glass. Collecting any single unit of garbage takes 11 minute.

You are also given a 00 indexed integer array travel, where travel[i] denotes the number of minutes required to travel from house i to house i + 1.

There are 33 garbage trucks, with each truck assigned to collect exclusively one type of garbage. All trucks start at house 00 and must visit houses in sequential order. A truck travels only as far as the last house that contains its assigned garbage type and does not need to visit any subsequent houses.

Return the minimum total number of minutes required to collect all the garbage from all houses.

Constraints:

  • 2≤2 \leq garbage.length ≤105\leq 10^5

  • garbage[i] consists of only the letters 'M', 'P', and 'G'.

  • 1≤1 \leq garbage[i].length ≤10\leq 10

  • travel.length == garbage.length −1- 1

  • 1≤1 \leq travel[i] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Amount of Time to Collect Garbage

med
30 min
Try to solve the Minimum Amount of Time to Collect Garbage problem.

Statement

You are given a 00 indexed array of strings garbage, where garbage[i] represents the assortment of garbage at the iextthi^{ ext{th}} house. Each character in garbage[i] represents one unit of garbage: 'M' for metal, 'P' for paper, and 'G' for glass. Collecting any single unit of garbage takes 11 minute.

You are also given a 00 indexed integer array travel, where travel[i] denotes the number of minutes required to travel from house i to house i + 1.

There are 33 garbage trucks, with each truck assigned to collect exclusively one type of garbage. All trucks start at house 00 and must visit houses in sequential order. A truck travels only as far as the last house that contains its assigned garbage type and does not need to visit any subsequent houses.

Return the minimum total number of minutes required to collect all the garbage from all houses.

Constraints:

  • 2≤2 \leq garbage.length ≤105\leq 10^5

  • garbage[i] consists of only the letters 'M', 'P', and 'G'.

  • 1≤1 \leq garbage[i].length ≤10\leq 10

  • travel.length == garbage.length −1- 1

  • 1≤1 \leq travel[i] ≤100\leq 100