Calculate Portfolio Rebalancing Deltas
Reported by candidates from Akuna Capital's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Akuna Capital reportedly put a portfolio rebalancing question in front of candidates in July 2026, and it's the kind of problem that looks too easy to trust. Three parallel arrays, one subtraction, one string table out. The opening angle is the data structure: it's just indexed arrays, no hash map needed. If you've got an OA invite, expect to spend your time on the details, not the algorithm. StealthCoder sits invisibly on your screen as a safety net if you blank on the output format or the overflow edge case during the live assessment.
The problem
A current portfolio and a target portfolio assign an integer allocation to each asset. The source method iterates over the assets in the current portfolio and records, for each asset, the target allocation minus the current allocation. For this exercise, the current portfolio is represented by parallel arrays assetIds and currentAllocations, and targetAllocations[i] is the target allocation for assetIds[i]. Return a two-column String[][] in the same order as assetIds. Each row must be [assetId, delta], where delta is the decimal string for targetAllocations[i] - currentAllocations[i]. Function rebalancePortfolio(assetIds: String[], currentAllocations: int[], targetAllocations: int[]) → String[][] Examples Example 1 assetIds = ["AAPL","BOND","CASH"] currentAllocations = [40,35,25] targetAllocations = [50,20,30] return = [["AAPL","10"],["BOND","-15"],["CASH","5"]] The target-minus-current differences are 50 - 40 = 10, 20 - 35 = -15, and 30 - 25 = 5. Each result remains paired with its asset ID. Example 2 assetIds = ["US_EQ","INTL_EQ"] currentAllocations = [50,50] targetAllocations = [50,50] return = [["US_EQ","0"],["INTL_EQ","0"]] Each target allocation equals its current allocation, so both rebalancing deltas are 0. Constraints assetIds.length == currentAllocations.length == targetAllocations.length. Every value in assetIds is nonempty and unique. -10^9 <= currentAllocations[i], targetAllocations[i] <= 10^9.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that there is no trick. Walk index i from 0 to n-1, compute targetAllocations[i] - currentAllocations[i], and emit [assetIds[i], String(delta)]. The asset IDs are unique and already aligned by index, so a hash map adds nothing. The real pitfall is overflow. Values run from -10^9 to 10^9, so a difference can hit 2*10^9, which breaks a 32-bit int. Cast to long before subtracting, then convert to a decimal string. Second pitfall: keep the order of assetIds exactly, and don't sort. Third: zero must print as "0" and negatives as "-15", which Long.toString handles. This is O(n) time and O(n) output space. If you freeze on the long cast or the String[][] construction, StealthCoder is the hedge during the live OA, reading the problem and handing you a clean solution.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Calculate Portfolio Rebalancing Deltas 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Akuna Capital's OA.
Akuna Capital reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Calculate Portfolio Rebalancing Deltas FAQ
How hard is the Akuna Capital rebalancing deltas problem really?+
Very easy on algorithm, one loop and a subtraction. The only way to lose points is sloppy details: integer overflow, wrong row order, or returning numbers instead of strings. Treat it as a careful-implementation question, not a thinking question.
What's the trick to Calculate Portfolio Rebalancing Deltas?+
Use a long for the subtraction. Allocations go up to 10^9 in magnitude, so target minus current can reach 2*10^9 and overflow a 32-bit int. Everything else is a straight index-aligned loop building [assetId, delta] rows.
Do I need a hash map for this problem?+
No. The three arrays are parallel, so index i links the asset, current, and target values. IDs are unique, but you never need to look one up. A hash map just adds code and risk without changing the result.
What output format does the function expect?+
A String[][] with one row per asset, in the same order as assetIds. Each row is the asset ID and the delta as a decimal string. Negative deltas keep the minus sign and zero is "0". No padding, no plus sign on positives.
How do I prepare for this in 48 hours?+
Don't grind. Write this one function in your OA language, including the long cast and the 2D string array setup. Then rehearse similar parallel-array problems so the boilerplate for building nested results is automatic.