A support desk gets chats[i] chats in minute i. In some minutes the agent on duty is overloaded (overloaded[i] is 1), and every chat in those minutes ends unhappy. In other minutes (0) every chat ends happy.
A manager can step in for exactly m minutes in a row once per day, and during those minutes every chat ends happy. Write mostHappyChats(chats, overloaded, m) that returns the largest possible number of happy chats for the day.
Input: chats = [1,0,1,2,1,1,7,5], overloaded = [0,1,0,1,0,1,0,1], m = 3 Output: 16
Without help 10 chats are happy. Stepping in for the last 3 minutes saves 1 + 5 = 6 more.
Input: chats = [4], overloaded = [0], m = 1 Output: 4
The only minute is already happy.
1 <= m <= chats.length <= 200000overloaded.length === chats.length0 <= chats[i] <= 1000overloaded[i] is 0 or 1.Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #132 Calm Spell for the Support Desk. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.