← AkunaCapital Interview Insights

AkunaCapital·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Akuna Capital data engineer interview with a coding problem around portfolio rebalancing. Pretty focused on Java and clean use of collections.

Questions Asked (1)

Q1

Given two portfolio objects each exposing a map of asset names to integer allocations, compute the per-asset difference (target minus current) and return the result in insertion-ordered fashion.

Algorithms & Data StructuresAPI & Integrations
Author's notes

The core trick here is not the math, it's remembering to use LinkedHashMap so you preserve the order from the target portfolio.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: whether the maps are mutable, if missing keys should be treated as zero, and what insertion order means when keys differ. Then propose an algorithm that iterates over the union of keys while preserving order, computes differences, and returns a new ordered map. Discuss time and space complexity and potential edge cases.

Pro tip: Mention that you would use a LinkedHashMap (or equivalent) to maintain insertion order, and explicitly define the order when keys are unique to one map—e.g., all keys from the target map first, then new keys from the current map. This shows attention to detail and prevents ambiguity.

1. Clarify requirements and constraints

Ask about mutability, handling of missing keys (treat as zero), and the exact insertion order when keys differ between maps. Confirm the expected output type (e.g., a new map).

2. Choose data structures and algorithm

Use an ordered map (like LinkedHashMap) for the result. Iterate over the union of keys, compute target - current, and insert into the result map in a defined order.

3. Define key ordering strategy

Decide and state the order: e.g., first all keys from the target map in their insertion order, then any additional keys from the current map in their insertion order. Alternatively, preserve the order of the first map encountered.

4. Implement and handle edge cases

Write code that handles missing keys as zero, avoids mutating inputs, and correctly computes differences. Consider empty maps, null inputs, and integer overflow.

5. Analyze complexity and test

State time complexity O(n+m) and space O(n+m). Walk through examples, including cases where keys differ, to verify correctness and order.

Key Points to Mention

  • Use of LinkedHashMap (or equivalent) to maintain insertion order.
  • Treat missing keys as zero allocations to avoid NullPointerException or incorrect results.
  • Define the insertion order explicitly when keys are not present in both maps.
  • Avoid mutating the input maps; return a new map.
  • Time complexity O(n+m) and space O(n+m) where n and m are the sizes of the maps.
  • Consider edge cases: empty maps, null inputs, and integer overflow (if allocations can be large).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.