← Akuna Capital Interview Insights

Akuna Capital·Data Scientist·Online Assessment (OA)·Intermediate

Intermediate
May 2026

Summary

Three coding problems for a Data Scientist role at Akuna Capital. The questions leaned more algorithmic than I expected for a DS position, so if you're prepping for this, treat it like a SWE screen.

Questions Asked (3)

Q1

Given a string and an integer k, find the longest substring containing at most k distinct characters. Return the earliest start index and the length. Target O(n) time.

Algorithms & Data Structures
Author's notes

Sliding window with a frequency map.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a sliding window with two pointers to maintain a window containing at most k distinct characters. Expand the right pointer to include new characters, and when the distinct count exceeds k, shrink the window from the left until it's valid again. Track the maximum length and earliest start index.

Pro tip: Clarify edge cases upfront (e.g., k=0, empty string, k >= distinct characters) and discuss how you'd handle them. Also, mention that the earliest start index is naturally maintained by only updating when a strictly longer window is found.

1. Clarify requirements and edge cases

Confirm the definition of 'substring' (contiguous), what to return if no such substring exists (e.g., empty string), and handle edge cases like k=0 or empty input.

2. Choose sliding window approach

Explain that a sliding window with two pointers (left and right) efficiently maintains a window with at most k distinct characters in O(n) time.

3. Maintain character frequency map

Use a hash map to count frequencies of characters in the current window. When the number of distinct characters exceeds k, move the left pointer and update the map until the window is valid again.

4. Track maximum length and earliest start

Whenever the window is valid, compare its length to the current maximum. If it's strictly greater, update the max length and record the start index (left pointer).

5. Return result and analyze complexity

After traversing the string, return the earliest start index and max length. Explain that each character is processed at most twice, giving O(n) time and O(k) space.

Key Points to Mention

  • Sliding window technique with two pointers for O(n) time complexity
  • Hash map to track character frequencies and distinct count
  • Shrinking the window when distinct characters exceed k
  • Updating max length only when a strictly longer window is found to ensure earliest start index
  • Handling edge cases: k=0, empty string, k >= number of distinct characters
  • Time complexity O(n) and space complexity O(k) due to the frequency map

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

Q2

For each node in an undirected weighted graph, compute the sum of the top-k incident edge weights, counting only edges with positive weight. Return an array of these sums. Target O(m log k) time.

Algorithms & Data Structures
Author's notes

This one was more interesting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints and edge cases, then propose an algorithm that processes each node's incident edges to maintain the top-k positive weights using a min-heap of size k. Analyze the time complexity to ensure O(m log k) and discuss potential optimizations or trade-offs.

Pro tip: Emphasize that you would confirm whether k is fixed across all nodes and whether the graph is large enough to require streaming or memory-efficient processing, showing attention to practical constraints.

1. Clarify requirements and edge cases

Ask about graph size, whether k is constant, if negative weights are ignored, and what to return if a node has fewer than k positive edges.

2. Design the algorithm

For each node, iterate through its incident edges, ignore non-positive weights, and maintain a min-heap of size k to keep the largest k weights.

3. Analyze complexity

Show that each edge is processed once per endpoint, and heap operations take O(log k), leading to O(m log k) total time.

4. Discuss implementation details

Explain how to build the adjacency list, handle isolated nodes, and efficiently compute sums from the heap.

5. Consider optimizations and trade-offs

Mention alternatives like sorting all incident edges (O(d log d)) and argue why the heap approach is better for large degrees.

Key Points to Mention

  • Use a min-heap of size k per node to track the top-k weights.
  • Ignore edges with non-positive weight.
  • Time complexity: O(m log k) because each edge is processed twice (once per endpoint) and each heap operation is O(log k).
  • Space complexity: O(m + n) for adjacency list and O(k) per node for heap (or O(nk) if stored separately).
  • Handle nodes with fewer than k positive edges by summing all available positive weights.
  • Potential optimization: if k is large, consider sorting all incident edges, but heap is better when k << degree.

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

Q3

Given a binary array, count the number of pairs (i, j) with i < j where A[i]=1 and A[j]=0. This equals the minimum adjacent swaps to push all 1s to the right. Solve in O(n) time and O(1) space.

Algorithms & Data Structures
Author's notes

Keep a running count of 1s seen so far.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the problem and confirm that the count of pairs (i, j) with i < j, A[i]=1, A[j]=0 equals the minimum adjacent swaps to move all 1s to the right. Then, present a single-pass O(n) time, O(1) space algorithm: iterate through the array, maintain a count of ones seen so far, and for each zero encountered, add the number of ones seen to a running total. Finally, discuss why this works and analyze complexity.

Pro tip: Emphasize that the algorithm uses constant extra space by only keeping two integer variables, which is crucial for large datasets. Also, mention that the same logic can be applied to move all 0s to the left by swapping the roles of 0 and 1.

1. Clarify the problem

Restate the problem in your own words and confirm that the count of pairs (i, j) with i < j, A[i]=1, A[j]=0 is indeed the minimum number of adjacent swaps to move all 1s to the right. Ask if there are any constraints or edge cases to consider.

2. Develop the algorithm

Explain the single-pass approach: initialize ones = 0 and swaps = 0. Iterate through the array; if the current element is 1, increment ones; if it is 0, add ones to swaps. This counts the number of inversions (1 before 0).

3. Analyze complexity

State that the algorithm runs in O(n) time because it makes a single pass, and uses O(1) extra space since only two integer variables are used regardless of input size.

4. Test with examples

Walk through a small example, such as [1,0,1,0], to demonstrate the algorithm. Show how the counts update and verify the result matches the expected number of swaps.

5. Discuss edge cases and extensions

Mention edge cases like all 1s, all 0s, or empty array. Optionally, discuss how to modify the algorithm to move all 0s to the left or to handle other similar problems.

Key Points to Mention

  • The problem is equivalent to counting inversions where a 1 appears before a 0.
  • Single-pass algorithm with two variables: ones count and swaps count.
  • Time complexity O(n) and space complexity O(1).
  • The algorithm works by accumulating the number of ones seen so far and adding it to the swap count for each zero encountered.
  • Edge cases: empty array, all ones, all zeros.
  • Potential extension: moving all 0s to the left by swapping roles.

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