FastPrepInvert Ad Visibility Bits
Problems/Invert Ad Visibility Bits

Invert Ad Visibility Bits

JP Morgan Chase logoJP Morgan Chase● EasyINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a JP Morgan Chase intern online assessment. The report does not give the function interface, a full worked example, or the limits on the numbers. The interface and examples here come straight from the stated bit-flip rules. Our version is about 98% the same as the reported question.

An e-commerce platform encodes the current visibility of its advertisements as a positive decimal integer base10. In the integer's binary representation, 1 means an ad is visible and 0 means it is hidden.

On every page load, invert every significant bit, beginning with the highest-order 1 bit and continuing through the rightmost bit:

  • Change each 1 to 0.
  • Change each 0 to 1.

Convert the resulting binary value back to decimal and return it.

Implement invertAdVisibility with one parameter, int base10, and return the inverted value as an int.

Function

invertAdVisibility(base10: int) → int

Examples

Example 1

base10 = 30return = 1

The significant binary representation of 30 is 11110. Flipping all five bits gives 00001, whose decimal value is 1.

Example 2

base10 = 10return = 5

The significant bits of 10 are 1010. Their inversion is 0101, which equals 5.

Example 3

base10 = 1return = 0

The only significant bit is 1. Flipping it produces 0.

Constraints

  • base10 is a positive integer that fits in a signed int.

More JP Morgan Chase Online Assessment questions

  • Find Total CostOA · Seen Oct 2026
  • Minimum Meeting RoomsOA · Seen Oct 2026
  • Count Dropped RequestsOA · Seen Oct 2026
  • Maximize Minimum Deployment DifficultyOA · Seen Oct 2026
  • Task SchedulingOA · Seen Oct 2026
  • Substring RemovalOA · Seen Oct 2026
  • Maximum Game Board ScoreOA · Seen Sep 2026
  • Minimum Digit Changes Between String HalvesOA · Seen Sep 2026
  • Same Substring Within BudgetOA · Seen Sep 2026
  • Maximum of Subarray MinimumsOA · Seen Aug 2026

Similar questions at other companies

  • Minimum Testers to Find the Poisoned BottleWalleye Capital · OA
  • Address on Same PageNVIDIA · OANVIDIA interview questions
  • Find the Missing Number from 1 to nGEP · OA
  • Count Times Using at Most Two DigitsLSEG · OALSEG interview questions
  • Minimum Tokens RemainingMicrosoft · OAMicrosoft interview questions
  • Minimum Operations to Make Binary PalindromicGoogle · OAGoogle interview questions
  • Powers of 2Oracle · OAOracle interview questions
  • Find the Lowest Set Bit PositionExpedia · OA · ONSITE INTERVIEWExpedia interview questions
  • Knights, Knaves and Their StatementsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions

JP Morgan Chase interview experiences

  • JPMorgan Chase Experienced SWE Java Interview: 1 Experience
  • JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
  • JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
  • JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
  • JP Morgan Chase Data and AI Intern Superday: 11 Experiences
  • JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)
All JP Morgan Chase interview questionsSee JP Morgan Chase hiring insights
Saved
class Solution {
    public int invertAdVisibility(int base10) {
      // Write your code here.
    }

}
Checking account…