Deterministic Percentage Rollout for a Feature Toggle Service

Last updated: November 29, 2026

Quick Overview

Write a function that decides whether a feature toggle is on for a given user, supporting a global kill switch, allow and deny lists, an optional user-group filter and a percentage rollout that stays stable for each user as the percentage increases.

Thoughtworks
Coding & Algorithms
Software Engineer
Thoughtworks
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Easy

0

0

0 solved


Write a function that decides whether a feature toggle is on for a given user, supporting a global kill switch, allow and deny lists, an optional user-group filter and a percentage rollout that stays stable for each user as the percentage increases.

Feature toggles and trunk-based development are long-standing Thoughtworks practices, so a short screen about evaluating toggles for a client's release is a natural fit. The interviewer checks rule precedence, deterministic hashing, and whether you reason about rollouts that must not flip users back and forth.

What the Interviewer Expects
  • States a clear precedence: kill switch, deny, allow, group filter, percentage
  • Uses a stable hash of flag name plus user id, not random()
  • Explains why raising the percentage only adds users
  • Salts by flag name so the same users are not always the guinea pigs
  • Writes a quick test that the observed share is near the target
Key Topics to Cover
Feature toggles
Consistent hashing
Progressive delivery
Trunk-based development
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
  • How would you roll out to 5% of accounts rather than 5% of users?
  • Where should evaluation run: server, client SDK or edge, and what are the trade-offs?
  • How do you stop toggles from piling up as technical debt in a client codebase?
  • How would you test code paths behind a toggle in CI?
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: a flag config (name, enabled, percent 0 to 100, allow set, deny set, optional groups) and a user (id, group). Output: boolean. A user who is in the rollout at 30% must still be in it at 50%, an...

High-Level Design

Precedence top to bottom: if the flag is disabled, off. Deny list wins over everything else, then allow list (useful for QA accounts). If groups are set, users outside them are off. Otherwise hash `fl...


Submit Your Answer
Markdown supported

Related Questions