← AkunaCapital Interview Insights

AkunaCapital·Software Engineer·Technical Phone Screen·Junior

Junior
May 2026

Summary

Short technical screen at Akuna Capital, just one coding problem focused on bit manipulation. Nothing fancy, but it's the kind of question that trips you up if you haven't thought about popcount in a while.

Questions Asked (1)

Q1

Given an array of integers, write a function that returns the total count of set bits (1-bits) across all elements in the array. The signature is: uint64_t count_bits(int* arr, uint64_t size).

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Straightforward if you know popcount exists.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem and edge cases, then present a clean solution using a bit-counting technique like Brian Kernighan's algorithm or a lookup table. Discuss trade-offs between simplicity, performance, and portability, and mention potential optimizations like SIMD or hardware intrinsics.

Pro tip: Mention that you'd consider using compiler intrinsics like __builtin_popcount for performance-critical code, but also provide a portable fallback. This shows awareness of both practical performance and portability concerns.

1. Clarify requirements and edge cases

Ask about input constraints (e.g., array size, integer range, negative numbers) and expected output type. Confirm whether the function should handle NULL pointers or zero size.

2. Choose a bit-counting method

Select an efficient algorithm such as Brian Kernighan's (n &= n-1) or a lookup table for 8/16-bit chunks. Explain why it's suitable for the context.

3. Implement the solution

Write the function signature correctly, iterate through the array, and accumulate the total count. Use appropriate types (uint64_t for size and return).

4. Analyze complexity and trade-offs

Discuss time complexity (O(n * k) where k is bits per integer, or O(n) with lookup) and space complexity. Compare with alternatives like hardware intrinsics.

5. Test and validate

Mention testing with edge cases: empty array, all zeros, all ones, negative numbers (if applicable), and large arrays.

Key Points to Mention

  • Brian Kernighan's algorithm: repeatedly clear the lowest set bit, runs in O(number of set bits).
  • Lookup table approach: precompute bit counts for 8-bit or 16-bit chunks, then sum for each integer.
  • Compiler intrinsics like __builtin_popcount or _mm_popcnt_u64 for performance, with portability caveats.
  • Time and space complexity analysis: O(n * k) vs O(n) with lookup, and O(1) extra space.
  • Handling negative numbers: if int is signed, cast to unsigned to avoid sign extension issues.
  • Edge cases: NULL pointer, size zero, and potential overflow of the return value (though uint64_t is large).

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