FastPrepCalculate Portfolio Rebalancing Deltas
Problems/Calculate Portfolio Rebalancing Deltas

Calculate Portfolio Rebalancing Deltas

Akuna Capital logoAkuna Capital● EasyOA
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source provides the complete Java method over portfolio interfaces but omits the interface definitions, numeric bounds, and examples. The judged core task matches the visible source at about 95%.

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.

More Akuna Capital problems

  • Delivery Management SystemOA · Seen Nov 2026
  • Count Server ReplacementsOA · Seen Nov 2026
  • Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
All Akuna Capital interview questionsSee Akuna Capital hiring insights
Saved
class Solution {
    public String[][] rebalancePortfolio(String[] assetIds, int[] currentAllocations, int[] targetAllocations) {
      // write your code here
    }
}
Checking account…