Pick At Most K Growth Experiments to Maximize Final Team Budget

Last updated: November 29, 2026

Quick Overview

A Lemon8 growth team starts with budget W; each experiment needs a minimum budget to launch and returns a pure gain when done, one at a time, and each can run once; return the largest budget after at most k experiments.

ByteDance
Coding & Algorithms
Software Engineer
ByteDance
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


A Lemon8 growth team starts with budget W; each experiment needs a minimum budget to launch and returns a pure gain when done, one at a time, and each can run once; return the largest budget after at most k experiments.

Lemon8 is one of ByteDance's newer apps, and resource-gated choices like this map to heap questions common in ByteDance screens. The interviewer checks that you combine sorting by requirement with a max-heap of unlocked gains and can argue why greedy is optimal.

What the Interviewer Expects
  • Sort experiments by required budget
  • Push newly affordable experiments into a max-heap of gains
  • Always run the largest available gain
  • Stop early when nothing is affordable
  • Prove the greedy choice with an exchange argument
Key Topics to Cover
heaps
greedy
sorting
exchange argument
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
  • Experiments can run in parallel up to c at a time.
  • Some experiments have negative expected gain with variance: how would you decide?
  • k is huge but n is small: optimize the loop bound.
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: k, starting budget W, and arrays costs and gains of length n. An experiment is launchable if its cost is at most the current budget; the cost is a threshold, not spent, and its gain is added wh...

High-Level Design

Gains only increase the budget, so the set of launchable experiments only grows. At each step, running the largest launchable gain is never worse: any other choice leaves a smaller budget, which unloc...


Submit Your Answer
Markdown supported