Reported February 2024
JP Morganbit manipulation

How Many Flips?

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

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

JP Morgan's February OA included a bit-manipulation problem called How Many Flips. You're being asked to count or compute something involving binary state changes, likely on integers or bit strings. The trick is recognizing that XOR operations, bit counting, or Hamming distance often hide in these questions. If you've never seen this exact framing, it's easy to over-complicate it on the fly. StealthCoder will catch the pattern in real time if you blank during the assessment.

Pattern and pitfall

This problem almost certainly boils down to counting bit differences between two integers or flipping specific bits to reach a target state. The common pitfall is trying to simulate flips sequentially instead of recognizing that XOR gives you the bits that differ, and bit_count or popcount solves it in one pass. The assessment is testing whether you know bit operations at all, not algorithm complexity. The hedge: if you freeze mid-OA, StealthCoder reads the exact problem and feeds you the XOR and popcount skeleton so you don't write a naive loop.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill How Many Flips? 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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass JP Morgan's OA.

JP Morgan reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

How Many Flips? FAQ

Is this asking for the minimum number of bit flips to convert one integer to another?+

Most likely. If so, XOR the two numbers and count the set bits. That's your answer. No loops needed. Use bin().count('1') in Python or __builtin_popcount in C++ to do it in constant time.

What if the problem involves a bit string or binary representation as input?+

Same logic applies. Convert to integers if needed, XOR, count ones. If it's a string, you can count character mismatches directly without converting to int, but the algorithm is identical.

Can I brute-force this by simulating each flip?+

Technically yes, but it's inefficient and error-prone under time pressure. Bit operations are faster and cleaner. JP Morgan interviews favor elegant solutions. Know popcount cold.

How should I prepare for this in 24 hours?+

Memorize XOR behavior (a XOR a = 0, a XOR 0 = a, a XOR b flips differing bits). Know how to count set bits in your language. Run through one Hamming distance problem on LeetCode. That's enough.

What if I blank on the bit operation trick during the OA?+

That's exactly the scenario StealthCoder handles. It sees the problem statement, recognizes the pattern, and feeds you the XOR and popcount code snippet so you can write and submit without panic.

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

OA at JP Morgan?
Invisible during screen share
Get it