Server Investment
Reported by candidates from Rippling's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on Rippling's Server Investment problem is looping over every possible sell count for every network. The OA was reported in September 2026, and with n up to 100000 and server counts up to 10^9, that brute force times out fast. Each network is independent, and the answer is a clean math problem. You pick how many servers to sell, then upgrade as many survivors as the budget allows. If you blank on the setup during the live assessment, StealthCoder runs invisibly as a safety net and hands you the approach.
The problem
A network security administrator manages several independent networks. For network i: numServers[i] is the number of servers initially present. money[i] is the available upgrade budget. sell[i] is the amount earned by selling one server. upgrade[i] is the cost to upgrade one server. You may sell any whole number of servers in a network. Sold servers cannot be upgraded, and the proceeds are added to that network's budget. You may then upgrade any number of the remaining servers that the resulting budget can afford. Return an array where element i is the maximum number of servers that can be upgraded in network i. Function getMaxUpgradedServers(numServers: int[], money: int[], sell: int[], upgrade: int[]) → int[] Examples Example 1 numServers = [4,3] money = [8,9] sell = [4,2] upgrade = [4,5] return = [3,2] For the first network, sell one server to obtain 8 + 4 = 12; the remaining three servers each cost 4 to upgrade. For the second network, sell one server to obtain 9 + 2 = 11; the remaining two servers cost 10 in total. Therefore the result is [3,2]. Example 2 numServers = [5,2] money = [50,0] sell = [1,3] upgrade = [10,4] return = [5,0] The first network can upgrade all five servers without selling any. In the second network, selling one server yields only 3, which cannot upgrade the one remaining server, so its maximum is 0. Constraints For this exercise, assume the four arrays have the same length n, where 1 <= n <= 100000. For this exercise, assume 0 <= numServers[i], money[i], sell[i] <= 10^9. For this exercise, assume 1 <= upgrade[i] <= 10^9. Use 64-bit integer arithmetic for funding calculations.
Reported by candidates. Source: FastPrep
Pattern and pitfall
For one network, say you sell s servers. Budget becomes money + s*sell. Remaining servers are N - s. Upgrades possible are min(N - s, (money + s*sell) / upgrade), using integer division. You want the max over s from 0 to N. The first term falls as s rises and the second rises, so the best s sits near where they cross. Binary search on s works: find the largest s where the budget covers all remaining servers. Check that s and s+1 around the crossover, or just evaluate a few candidates. You can also solve the crossover algebraically and clamp to [0, N]. The pitfall is overflow: s*sell reaches 10^18, so use 64-bit ints, and in languages with smaller ints, cast first. Also handle sell = 0, where selling never helps. StealthCoder is the hedge if the crossover logic slips under time pressure.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Server Investment cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Rippling's OA.
Rippling reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Server Investment FAQ
What's the trick in Rippling's Server Investment?+
Treat each network separately and write the result as a function of s, the number sold: min(N - s, (money + s*sell) / upgrade). One term decreases, the other increases, so the max is at the crossover. Binary search or direct algebra finds it in O(log N) per network.
Why does brute force fail here?+
Server counts go up to 10^9 and there can be 100000 networks. Trying every sell count per network is far too slow. You need O(log N) or O(1) per network, which the crossover insight gives you.
Do I need to worry about overflow?+
Yes. sell and s can both reach 10^9, so s*sell can hit 10^18. That fits in a signed 64-bit integer but not 32-bit. Use long in Java or C++, and cast before multiplying so the product isn't computed in 32 bits.
Is selling ever worse than not selling?+
Often. Each sold server removes a candidate for upgrade, and if sell is less than upgrade cost, selling can reduce the total. Example 2 shows it: selling one server for 3 can't fund a 4-cost upgrade. Always compare against s = 0.
How do I prepare for this in 48 hours?+
Write the formula for one network by hand, then code it with binary search on s and test both examples. Add edge cases: N = 0, sell = 0, huge values. Practice reasoning about a tradeoff between two opposing terms, since that's the core idea.