Get Max Deletions
Reported by candidates from JP Morgan's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
JP Morgan's September OA included a deletion optimization problem where you need to maximize the number of deletions under some constraint. You're being tested on whether you can spot the greedy or dynamic-programming angle, not raw coding speed. The trick is recognizing what stays versus what gets removed, and in what order. If the problem text didn't click during your first read, StealthCoder is your safety net to surface the pattern in real time.
Pattern and pitfall
Without the full problem text, the core challenge is likely one of two shapes: either a greedy approach where you delete elements that satisfy a condition in optimal order, or a DP state where you track maximum deletions across subproblems. JP Morgan tends to test optimization under constraints, so you're probably looking at either string/array operations with deletion rules, or a substring/subsequence angle. The common pitfall is deleting greedily without checking if later choices would yield more deletions. Build out a few small examples by hand first to see if greedy holds. If it doesn't, sketch a DP recurrence before coding.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Get Max Deletions 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass JP Morgan's OA.
JP Morgan reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Get Max Deletions FAQ
Is this a greedy problem or DP?+
Both patterns surface at JP Morgan. Test greedy on small examples first. If it fails, pivot to DP with memoization or a bottom-up table. The hint is in whether order matters. If you delete A before B and get a different result than B before A, you need DP.
What's the most common pitfall on deletion problems?+
Deleting immediately without checking downstream impact. Build the candidate solution first, then verify it's optimal. Trace through a length-3 and length-4 case by hand. That's faster than debugging code.
How do I approach this in under 40 minutes?+
Spend 5 minutes on examples. Sketch the recurrence or greedy rule on paper. Code only once you see the pattern clearly. Test edge cases: empty input, single element, all elements deletable, none deletable.
Is this still asked at JP Morgan in late 2024?+
Yes. Deletion and substring optimization are staples in their OA. They test pattern recognition and constraint handling, which map to real trading and risk systems.
Should I implement both approaches or pick one?+
If you see greedy clearly and verify it on examples, code that first. If you blank, implement a brute-force DP with memoization. Both will pass within time limits on JP Morgan's tests.