Minimize Total Time
Learn this problemProblem statement
You are given two integer arrays:
int[] multiples: the multipliers available in the shopint[] prices: the corresponding prices for each multiplier
Both arrays have the same length n, and the i-th multiplier (multiples[i]) costs prices[i] coins to purchase.
You start with:
When you purchase a multiplier, your coin gain rate is multiplied by that value. For example:
You can only make purchases when you have enough coins to afford the multiplier.
Your goal is to purchase all the multipliers, in some order, such that the total time taken to finish all purchases is minimized.
Function
minimizeTotalTime(multiples: int[], prices: int[]) → int[]
Complete the function minimizeTotalTime in the editor.
minimizeTotalTime has the following parameters:
int[] multiples: an array of multipliers available in the shopint[] prices: an array of corresponding prices for each multiplier
Returns
int[]: an array of indices representing the order in which to purchase the multipliers to minimize the total time
Examples
Example 1
multiples = [3, 100, 30]prices = [5, 30, 15]return = [0, 2, 1]Constraints
:OMore Google problems
- Deduplicate Logs: Keep FirstONSITE INTERVIEW · Seen Jul 2026
- Deduplicate Logs: Keep LatestONSITE INTERVIEW · Seen Jul 2026
- Find a Template Across Binary-Tree LeavesONSITE INTERVIEW · Seen Jul 2026
- Maximum Programmer-Problem MatchingONSITE INTERVIEW · Seen Jul 2026
- Minimum Direction ViolationsONSITE INTERVIEW · Seen Jul 2026
- Stream Latest Log VersionsONSITE INTERVIEW · Seen Jul 2026
- Stream Unique Logs in Timestamp OrderONSITE INTERVIEW · Seen Jul 2026
- Top-K IP Addresses from File RecordsONSITE INTERVIEW · Seen Jul 2026