Reported February 2026
Wells Fargostack

Minimum Remaining Length

Reported by candidates from Wells Fargo's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Wells Fargo OA. Under 2s to a working solution.
Founder's read

The Wells Fargo OA reported in February 2026 hands you a string of only 'A' and 'B' and lets you delete "AB" or "BB" as many times as you want. Sounds like a stack problem, and it is, but there's a shortcut that makes it a one-pass counter. The example "BABBA" collapses down to length 1, and that tells you most of what you need. If you blank under the timer, StealthCoder runs invisibly during the live assessment and can hand you the solution. Read the trick below first and you probably won't need it.

The problem

You are given a string seq made up only of the characters 'A' and 'B'.
You may repeatedly perform the following operation:
Delete any occurrence of the substring "AB" or "BB".
After deletion, the remaining parts of the string are concatenated.
Your task is to determine the minimum possible length of the string after performing any number of valid deletions.
Note: A substring refers to a contiguous sequence of characters.
Return the minimum remaining length.

Function
getMinimumRemainingLength(seq: String) → int

Examples
Example 1
seq = "BABBA"
return = 1

Reported by candidates. Source: FastPrep

Pattern and pitfall

Think about what survives. Any B can be deleted if there's a character before it: A followed by B is "AB", B followed by B is "BB". So a B only stays if it's at the very front with nothing before it. An A can only be removed by a B right after it. Scan left to right with a stack or counter. On B, if the stack has anything, pop it. If empty, push B. On A, push A. Final stack size is the answer. Check against "BABBA": B pushed, A pushed, B pops A, B pops B, A pushed. Length 1. The common pitfall is simulating deletions with string replace in a loop, which goes quadratic. Another is forgetting that a leading B has nothing to pair with. Use the stack, run it in O(n). StealthCoder is your hedge in the live OA if the stack logic slips under pressure.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Minimum Remaining Length 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 StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as minimum string length after removing substrings. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Wells Fargo's OA.

Wells Fargo 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.

Minimum Remaining Length FAQ

What's the trick for Minimum Remaining Length?+

Treat it as a stack. Push every A. On a B, pop if the stack is non-empty, otherwise push the B. Every B with something before it can be deleted through "AB" or "BB". The final stack size is your answer. It's a single pass.

How hard is this problem really?+

Easy to medium. The statement looks like a deletion simulation, but once you see a B always cancels the previous character, it's a few lines. The main risk is overcomplicating it with repeated string replacement.

Can I solve it without a stack?+

Yes. Keep a single integer for the current length. On A, increment. On B, decrement if the length is above zero, otherwise increment. That mirrors the stack exactly since you only need its size, not its contents.

What edge cases should I test?+

Test an empty string, a string of all A's (nothing deletes, so length stays n), a string starting with B like "BA", and all B's like "BBB", which leaves 1. Also run the sample "BABBA" and confirm you get 1.

How do I prep for this in 48 hours?+

Write the stack version once from memory, then the counter version. Run a few hand traces on short strings. Also glance at similar adjacent-pair removal problems so the pattern feels familiar. Don't memorize code, memorize the rule for B.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Wells Fargo.

OA at Wells Fargo?
Invisible during screen share
Get it