FastPrepLongest Consecutive One Bits in a 32-Bit Integer
Problems/Longest Consecutive One Bits in a 32-Bit Integer

Longest Consecutive One Bits in a 32-Bit Integer

Google logoGoogle● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks for the longest run of consecutive ones in a 32-bit input, and gives binary 11011110111 -> 4. Here the input is the matching integer, in the non-negative signed range. Our version is about 95% the same as the reported question.

Given a non-negative signed 32-bit integer value, return the maximum number of consecutive 1 bits in its 32-bit binary representation.

Leading zeroes are included conceptually but do not affect the result.

Function

longestOneBitRun(value: int) → int

Examples

Example 1

value = 1783return = 4

1783 is binary 11011110111; the longest run has length four.

Example 2

value = 0return = 0

There are no one bits.

Example 3

value = 31return = 5

31 is five consecutive one bits.

Constraints

  • 0 <= value <= 2,147,483,647.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Count the 1 Bits in a 32-Bit ValueAmazon · PHONE SCREEN
  • Find the Unique Element Among PairsChubb · PHONE SCREENChubb interview questions
  • XOR Pseudorandom SequenceBaseten · PHONE SCREENBaseten interview questions
  • Maximize Binary XOR with a Set-Bit LimitJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
  • Swap Adjacent NibblesArista Networks · PHONE SCREENArista Networks interview questions
  • The One Repeated NumberAdobe · PHONE SCREENAdobe interview questions
  • CPU Register Bitwise OperationsHeadlands Technologies · PHONE SCREENHeadlands Technologies interview questions
  • Integer to Binary RepresentationThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
  • Spelling Bee Word FilterBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Find the Element With Odd FrequencyZscaler · PHONE SCREENZscaler interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int longestOneBitRun(int value) {
        // Write your code here.
    }
}
Checking account…