FastPrepMaximize Workday Earnings
Problems/Maximize Workday Earnings

Maximize Workday Earnings

Citadel logoCitadel● MediumINTERNFULLTIMENEW GRADOAPHONE SCREENONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report establishes daily earnings, a consecutive-work bonus, and the option to convert up to k days off into workdays. It omits a portable interface and numeric bounds. The judged core task matches the visible source at about 93%.

You are given a work schedule schedule. Each character is W for a workday or O for a day off.

  • Every workday earns dailyPay.
  • A workday also earns consecutiveBonus when the immediately preceding day is a workday.
  • You may change at most k occurrences of O into W.

Return the maximum total earnings after the changes. Both pay values are nonnegative, so changing an additional available day off can never reduce the result.

Function

maximizeEarnings(schedule: String, k: int, dailyPay: long, consecutiveBonus: long) → long

Examples

Example 1

schedule = "WOWO"k = 1dailyPay = 10consecutiveBonus = 5return = 40

Changing the middle day off produces WWWO. Three workdays earn 30, and the two adjacent workday pairs earn 10 in bonuses.

Example 2

schedule = "OOOO"k = 2dailyPay = 10consecutiveBonus = 5return = 25

Choose two adjacent days. The two workdays earn 20, and their one adjacency earns a bonus of 5.

Example 3

schedule = "WWOOOW"k = 2dailyPay = 10consecutiveBonus = 5return = 65

Use both changes next to the leading run, producing four consecutive workdays and one separated workday. Five workdays earn 50, and three adjacencies earn 15.

Constraints

  • 1 <= schedule.length <= 200000
  • schedule[i] is W or O.
  • 0 <= k <= schedule.length
  • 0 <= dailyPay, consecutiveBonus <= 10^9
  • The answer fits in a signed 64-bit integer.

More Citadel problems

  • Portfolio Tickers with Constant-Time Random PickPHONE SCREEN · Seen Nov 2026
  • Square Root FunctionPHONE SCREEN · Seen Oct 2026
  • Reachable Transfer PositionsPHONE SCREEN · Seen Oct 2026
All Citadel interview questionsSee Citadel hiring insights
Saved
class Solution {
    public long maximizeEarnings(String schedule, int k, long dailyPay, long consecutiveBonus) {
      // write your code here
    }
}
Checking account…