Calculate Portfolio Rebalancing Deltas
Learn this problemProblem statement
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
assetIdsis nonempty and unique. -10^9 <= currentAllocations[i], targetAllocations[i] <= 10^9.
More Akuna Capital problems
- Binary CircuitOA · Seen Jul 2026
- Items SortOA · Seen Jul 2026
- Minimize Malware Spread by Removing a NodeOA · Seen Jul 2026
- Maximum K-Star SumOA · Seen Jul 2026
- Profitable Project PairsOA · Seen Jul 2026
- Array Challenge (QR Intern)OA · Seen Jul 2026
- Communications HandlerOA · Seen Jul 2026
- K Smallest SubstringOA · Seen Jul 2026