Minimize Length of Array Using Operations
A medium-tier problem at 35% community acceptance, tagged with Array, Math, Greedy. Reported in interviews at BNY Mellon and 1 others.
You're given an array and a single operation: pick any two elements that share a common divisor greater than one, remove them, and add their LCM back. The goal is to shrink the array as much as possible. BNY Mellon and HashedIn both ask this. The acceptance rate sits at 35 percent, so most candidates either miss the greedy insight or get trapped optimizing the wrong direction. This is the kind of problem where your first instinct fails. If you hit it live and blank on the strategy, StealthCoder solves it in seconds, invisible to the proctor.
Companies that ask "Minimize Length of Array Using Operations"
Minimize Length of Array Using Operations 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. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe trap is treating this greedily on pair-by-pair operations without seeing the bigger picture. The real pattern: elements that can be merged (via their GCD) form clusters, and you want to merge within clusters until only one element remains per cluster. The key insight is that GCD relationships define which elements can ever be combined, so you're really looking at connected components in a graph where edges exist between numbers sharing a common factor. Once you identify those components, the math becomes clear. Array, Math, Greedy, and Number Theory all converge here. Most candidates waste time simulating operations; the winners think in terms of prime factorization and which elements are 'connected' by shared factors. StealthCoder is the hedge for the one time you don't see that abstraction under pressure.
Pattern tags
You know the problem.
Make sure you actually pass it.
Minimize Length of Array Using Operations 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. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Minimize Length of Array Using Operations interview FAQ
Is this actually a greedy problem or a graph problem in disguise?+
Both, but it's secretly graph-first. You need to identify which elements can ever be merged by finding connected components. Only then does the greedy optimization (merging within each component) apply. Most people skip the component step and lose points on correctness or edge cases.
Why does 34 percent acceptance feel so low for a Medium?+
Because the greedy interpretation is intuitive but wrong, and candidates waste time debugging broken simulations. The real trick is recognizing this as a connectivity problem. Once you see it, the acceptance rate makes sense.
How does GCD connect to the merge operation?+
Two elements can only merge if GCD is greater than one. That GCD relationship defines whether they're in the same connected component. Prime factorization tells you which components can eventually collapse to a single element.
Do I need to implement the actual merges or can I just count components?+
You can count. If you can prove two elements share a common prime factor, they're in the same component and will eventually merge into one. The final array length is the number of components, not the result of simulating operations.
Does BNY Mellon ask this as a screening or onsite question?+
The data shows both BNY Mellon and HashedIn have asked it, but the input doesn't specify the stage. Treat it as a live-assessment risk either way. It's the kind of problem that kills you if you don't spot the pattern.
Want the actual problem statement? View "Minimize Length of Array Using Operations" on LeetCode →