Read a Feature Flag Bitmask Stored as a Linked List of Bits

Last updated: November 29, 2026

Quick Overview

A rollout system stores a feature flag bitmask as a singly linked list of 0 and 1 nodes, most significant bit first. Return the integer value in one pass.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


A rollout system stores a feature flag bitmask as a singly linked list of 0 and 1 nodes, most significant bit first. Return the integer value in one pass.

An Online Assessment style warm-up at Google: short, but it checks that you can accumulate a value without first reversing the list or computing its length. Strong candidates mention the bit shift form and overflow in fixed-width languages.

What the Interviewer Expects
  • Accumulate value = value * 2 + bit while walking
  • Avoid reversing the list or counting the length first
  • Mention the shift form (value << 1) | bit
  • Discuss overflow if the list is longer than 63 bits in Java or C++
  • Validate that nodes are only 0 or 1
Key Topics to Cover
linked list
bit manipulation
number representation
single pass
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Return the value modulo 10^9 + 7 for very long lists.
  • Bits are stored least significant first. What changes?
  • Increment the number by one in place in the list.
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: head of a non-empty list of 0 and 1 nodes, MSB first.
  • Output: the integer it represents.
  • One pass, O(1) extra space....
High-Level Design

Reading binary left to right works exactly like reading decimal left to right: each new digit shifts everything seen so far one place and adds the new digit. So keep a running value, and for each node...


Submit Your Answer
Markdown supported