← Visa Interview Insights

Visa·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Interviewed for a software engineering role at Visa and got hit with a pretty meaty dynamic programming problem about counting distinct coin sums. The problem had enough layers to it that I was still thinking about edge cases after the call ended.

Questions Asked (1)

Q1

You have two arrays representing coin denominations and their available counts. How many distinct positive sums can you form using at most the given number of coins for each denomination? Walk through your algorithm, its time and space complexity, and how you'd handle cases where the maximum reachable sum gets very large (up to around 1 million).

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is basically a bounded knapsack variant and I knew that going in, but the 'distinct sums' framing threw me for a second because I kept second-guessing whether I needed to track combinations or just reachability.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a bounded knapsack reachability problem, using a boolean array to track achievable sums. Optimize with binary splitting of coin counts or a monotonic queue to handle up to 1 million sums efficiently. Discuss time and space complexity, and address large sum handling with bitsets or memory-conscious techniques.

Pro tip: Mention that Visa cares about scalability and real-world constraints—highlight how your solution avoids O(maxSum * totalCoins) by using binary splitting or monotonic queues, and note that bitset operations can give a 64x speedup in practice.

1. Clarify and Define the Problem

Restate the problem: given denominations and counts, count distinct positive sums achievable using at most the given number of each coin. Confirm that coins are indistinguishable and order doesn't matter.

2. Choose a Reachability Approach

Use a boolean DP array where dp[s] indicates if sum s is achievable. Initialize dp[0]=true and iterate through each denomination, updating reachable sums within the allowed count.

3. Optimize for Bounded Counts

Apply binary splitting to convert each coin count into powers of two, turning the problem into 0/1 knapsack. Alternatively, use a monotonic queue to process each denomination in O(maxSum) time.

4. Analyze Complexity and Handle Large Sums

State time complexity: O(maxSum * sum(log(count_i))) with binary splitting, or O(maxSum * numDenominations) with monotonic queue. Space is O(maxSum). For maxSum ~1e6, mention bitset optimization for speed and memory.

5. Discuss Trade-offs and Edge Cases

Compare binary splitting vs. monotonic queue: binary splitting is simpler but may be slower for large counts; monotonic queue is optimal but complex. Handle edge cases like zero counts, duplicate denominations, and sums exceeding 1e6.

Key Points to Mention

  • Bounded knapsack formulation and boolean DP array for reachability.
  • Binary splitting optimization to reduce coin counts to O(log count) items.
  • Monotonic queue optimization for O(maxSum) per denomination.
  • Time complexity: O(maxSum * sum(log(count_i))) or O(maxSum * numDenominations).
  • Space complexity: O(maxSum), with bitset reducing constant factor.
  • Handling large maxSum (~1e6) via bitsets or memory-efficient arrays.

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