Non-decreasing Array
A medium-tier problem at 25% community acceptance, tagged with Array. Reported in interviews at Cashfree and 0 others.
Non-decreasing Array is a medium-difficulty array problem with a 25% acceptance rate, which means three quarters of candidates who attempt it don't pass. Cashfree has asked this one. The trap is that you can't just count violations and decide if it's fixable in one move. You need to understand when modifying one element can actually repair the sequence, and when it can't. If you blank on the logic during the live assessment, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Non-decreasing Array"
Non-decreasing Array is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.
Get StealthCoderThe problem asks: can you make an array non-decreasing by modifying at most one element. The naive approach fails because you might spot a violation at index i, but fixing arr[i] might break the relationship with arr[i+1], or fixing arr[i+1] might break arr[i] and arr[i-2]. The real insight is that when you find a violation (arr[i] > arr[i+1]), you have two choices: lower arr[i] or raise arr[i+1]. Then you check both candidates to see if either fix maintains non-decreasing order across the entire array. Most candidates waste time trying to optimize prematurely instead of just trying both edits. StealthCoder handles this by checking all violation points and the two repair options for each.
Pattern tags
You know the problem.
Make sure you actually pass it.
Non-decreasing Array recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Non-decreasing Array interview FAQ
Why is this acceptance rate so low if it's just 'medium'?+
The greedy intuition fails. Candidates spot a violation, fix it locally, and assume they're done. But one edit can cascade. You have to test both repair options for every violation, not just the first one you see. Most people don't think through the two-choice branch.
Can I just fix violations left-to-right and stop at one?+
No. Fixing arr[i] might break arr[i-1] and arr[i]. You can only claim success if the entire array is non-decreasing after your single edit. You need to simulate both options (lower arr[i] or raise arr[i+1]) and check the full result.
What's the trick to not overcomplicate it?+
Find the first index where arr[i] > arr[i+1]. Then try two fixes: set arr[i] = arr[i+1], or set arr[i+1] = arr[i]. For each fix, verify the entire array is now non-decreasing. If either works, return true. If no violation exists, return true immediately.
How often does Cashfree ask this?+
It's in their reported interview history. Array problems are foundational, so even one-off appearances matter. It's a good signal that you can handle constraints and edge cases under pressure.
What's the worst-case scenario during the OA?+
You spend 15 minutes writing a solution that handles the first violation correctly but doesn't check if that single edit breaks the rest of the array. You submit, fail a test case, and have no time to debug. StealthCoder avoids that by showing the two-option branch upfront.
Want the actual problem statement? View "Non-decreasing Array" on LeetCode →