Maximum Decrypted Score
Reported by candidates from Microsoft's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The Microsoft OA reported in September 2026 looks like a simple window problem, and then one edge case wrecks the naive version. You've got scores, a decryption flag per file, and one operation: decrypt a contiguous block of at most k files. Most people grab the best window of k and forget that already decrypted files inside it add nothing new. The core is sliding window over the encrypted files only, added to a fixed base sum. If you freeze on the day, StealthCoder runs invisibly as a safety net and hands you the clean solution.
The problem
You are given two arrays of equal length: scores and decryptionStatus. The value scores[i] is the sensitivity score of file i. The value decryptionStatus[i] describes the current state of file i: 1 means the file is already decrypted. 0 means the file is still encrypted. You may perform the following operation at most once: choose a contiguous subarray containing at most k files and decrypt every file in that subarray. Return the maximum possible sum of the scores of all decrypted files after the optional operation. Function maximumDecryptedScore(scores: int[], decryptionStatus: int[], k: int) → long Examples Example 1 scores = [7,4,3,5] decryptionStatus = [1,0,0,0] k = 2 return = 15 The already decrypted first file contributes 7. Choosing indices [2,3] decrypts files with scores 3 and 5, producing 7 + 3 + 5 = 15, which is greater than the totals from the other length-two segments. Constraints 1 <= scores.length <= 10^3 decryptionStatus.length == scores.length 0 <= scores[i] <= 10^9 decryptionStatus[i] is either 0 or 1. 1 <= k <= scores.length
Reported by candidates. Source: FastPrep
Pattern and pitfall
Split the answer into two parts. Base is the sum of scores where status is 1. Gain is the sum of scores where status is 0 inside the chosen window. Build a gain array where gain[i] = scores[i] if status is 0, else 0. Then find the max sum of any window of length k. Since scores are nonnegative, a window of exactly k beats a shorter one, and if k equals the array length you just take everything. The trap is adding the whole window score and double counting files that were already decrypted. The other trap is overflow: scores reach 10^9 and n reaches 1000, so the total hits 10^12. Use a 64-bit integer. With n at 1000 even an O(n*k) brute force passes, but the sliding window is cleaner. If you blank mid-assessment, StealthCoder is the hedge that gives you this in seconds.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Maximum Decrypted Score cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Microsoft's OA.
Microsoft reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum Decrypted Score FAQ
How hard is Maximum Decrypted Score really?+
Easy to medium. The idea is a fixed-length sliding window plus a base sum. Anyone comfortable with prefix sums or windows can finish it quickly. The difficulty is in not double counting files that are already decrypted.
What's the trick for the Microsoft version?+
Separate the already decrypted total from the gain. Zero out scores of decrypted files in a gain array, then find the max window sum of length k. Add that to the base. Don't sum raw scores over the window.
Do I need a window of exactly k or at most k?+
Exactly k is enough because scores are nonnegative, so a longer window never hurts. When k equals the array length, the window covers everything. Clamping isn't needed since k is bounded by the array length.
Will integer overflow matter here?+
Yes. Scores go up to 10^9 and there can be 1000 files, so sums reach about 10^12. That overflows a 32-bit int. Use long in Java or C++, and Python handles it natively. The function signature returns a long for this reason.
How do I prepare in 48 hours for this kind of OA?+
Practice fixed-size sliding window and prefix sum problems, and get used to splitting a total into a base plus a gain. Write the brute force first, then optimize. Test with all zeros, all ones, k=1, and k=n before you submit.