Airbnb Host's Strategic Pricing
As an Airbnb host, optimizing your pricing strategy is crucial for maximizing revenue while maintaining guest satisfaction. This problem simulates a scenario where you need to decide between standard and premium pricing for your listing over a series of days, balancing higher revenue potential with strategic cooldown periods to avoid over-saturation.
Implement the maxTotalRevenue function that calculates the maximum possible total revenue an Airbnb host can achieve over N days, given the daily standard and premium revenues, and a constraint on setting premium prices.
Function Signature (TypeScript):
function maxTotalRevenue(standardRevenues: number[], premiumRevenues: number[], K: number): number
Parameters:
standardRevenues: An array of integers, where standardRevenues[i] represents the revenue generated if a standard price is set for day i. The array length is N.premiumRevenues: An array of integers, where premiumRevenues[i] represents the revenue generated if a premium price is set for day i. The array length is N.K: An integer representing the minimum number of consecutive standard-priced days that must follow a premium-priced day before another premium-priced day can be set. Specifically, if a premium price is set on day i, then days i+1, i+2, ..., i+K must be set to standard prices (or be beyond the N-day period). The next earliest day a premium price can be set is i+K+1.Return Value:
N days.0 to N-1.N is the length of standardRevenues (and premiumRevenues).K=0, there's no cooldown period, meaning premium pricing can be set on consecutive days.K is large such that i+K+1 exceeds N, it simply means no further premium bookings can be made after day i.Examples
Example 1
Input:
standardRevenues = [10, 2, 8], premiumRevenues = [15, 10, 20], K = 1
Output:
37
Note:
N=3, K=1.
Example 2
Input:
standardRevenues = [5, 5, 5, 5, 5], premiumRevenues = [20, 1, 1, 20, 1], K = 1
Output:
55
Note:
N=5, K=1.
Example 3
Input:
standardRevenues = [1, 1, 1], premiumRevenues = [10, 10, 10], K = 0
Output:
30
Note:
N=3, K=0. No cooldown. Choosing premium every day is optimal.
Constraints
1 <= N <= 10^50 <= K < N-1000 <= standardRevenues[i], premiumRevenues[i] <= 1000K cooldown period.N, K=0, negative revenues, indices out of bounds).Loading editor...