Interview Questions/Coding/Startup Acquisition Strategy

Startup Acquisition Strategy

Preview mode. Log in to edit, run, submit, and save progress.

Easy

Startup Acquisition Strategy

A company starts with an initial amount of capital represented by the integer capital. There are n startups available for acquisition, where startups[i] represents the valuation of the i-th startup. The company can acquire the startups in any order. A startup can only be acquired if the company's current capital is greater than or equal to its valuation. After acquiring a startup, the company's capital increases by the valuation of that startup. Return true if it is possible to acquire all startups. Otherwise, return false. Input Format An integer capital An integer array startups Output Format Return true if all startups can be acquired. Otherwise return false.

Examples

Example 1
Input:
capital = 10
startups = [4, 9, 23]

Output
true

Explanation
Acquire startup worth 4.
Capital = 10 + 4 = 14
Acquire startup worth 9.
Capital = 14 + 9 = 23
Acquire startup worth 23.
Capital = 23 + 23 = 46
All startups can be acquired.
Output:
true

Explanation: Acquire startup worth 4. Capital = 10 + 4 = 14 Acquire startup worth 9. Capital = 14 + 9 = 23 Acquire startup worth 23. Capital = 23 + 23 = 46 All startups can be acquired.

Approach hint

Try acquiring cheaper startups before expensive ones.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

solution.cpp