Practice Maximum Profit of Operating a Centennial Wheel
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
You are the operator of a Centennial Wheel that has four gondolas, and each gondola has room for up to four people. You have the ability to rotate the gondolas counterclockwise, which costs you runningCost dollars. You are given an array customers of length n where customers[i] is the number of new customers arriving just before the ith rotation (0-indexed). This means you must rotate the wheel i times before the customers[i] customers arrive. You cannot make customers wait if there is room in the gondola. Each customer pays boardingCost dollars when they board on the gondola closest to the ground and will exit once that gondola reaches the ground again. You can stop the wheel at any time, including before serving all customers. If you decide to stop serving customers, all subsequent rotations are free in order to get all the customers down safely. Note that if there are currently more than four customers waiting at the wheel, only four will board the gondola, and the rest will wait for the next rotation. Return the minimum number of rotations you need to perform to maximize your profit. If there is no scenario where the profit is positive, return -1.
Source: Maximum Profit of Operating a Centennial Wheel on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
customers = [8,3], boardingCost = 5, runningCost = 6
3
# Example 2
customers = [10,9,6], boardingCost = 6, runningCost = 4
7
# Example 3
customers = [3,4,0,5,1], boardingCost = 1, runningCost = 92
-1
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Profit of Operating a Centennial Wheel.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.