Maximize Earnings

Company: Rippling_4sep

Difficulty: medium

Problem Statement

Maximize Earnings Problem Description An employee is paid a fixed amount of fixedPay dollars for each day they work. On a workday they also receive an extra bonus dollars if they also worked the day before. The employee is planning a work schedule for n days. The plan is given as a binary string schedule of length n , where '1' means the employee works that day and '0' means a day off. The employee may change at most k days off ( '0' ) into workdays ( '1' ). A workday can never be changed into a day off. After the changes, the earnings for each day are: a day off earns 0 ; a workday earns fixedPay , plus bonus if the previous day is also a workday in the changed schedule. The first day never earns the bonus, because it has no previous day. Find the maximum total earnings over the n days. Complete the function getMaxEarnings(schedule, k, fixedPay, bonus) , which returns this maximum as a 64-bit integer. Input Format Read from standard input. schedule k fixedPay bonus Line 1 contains the