← Capital One Interview Insights

Capital One·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Capital One SWE interview with a string manipulation problem that looks straightforward but has some gotchas around counting ordered pairs. The approach they're fishing for is smarter than brute force and it took me a minute to get there.

Questions Asked (1)

Q1

Given a list of non-negative integers and a target integer, count the number of ordered index pairs (i, j) where concatenating the string forms of numbers[i] and numbers[j] equals the string form of the target.

Algorithms & Data Structures
Author's notes

First thing I did was ask about i == j, which was actually the right instinct.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints and edge cases, then propose an efficient solution using a hash map to count occurrences of each number's string representation. Iterate through the list, for each number compute the required complementary part of the target string, and look up its count in the map to accumulate ordered pairs.

Pro tip: Discuss how to handle leading zeros and the fact that numbers are non-negative, and mention that the hash map approach avoids O(n^2) brute force, showing you optimize for large inputs.

1. Clarify the problem

Ask about constraints: list size, maximum number value, target length, and whether numbers can have leading zeros in their string form. Confirm that ordered pairs (i, j) include i = j and that concatenation order matters.

2. Brute force baseline

Mention the straightforward O(n^2) approach: iterate over all pairs, concatenate strings, and compare to target. This establishes correctness but is inefficient for large n.

3. Optimize with hash map

Build a frequency map of string representations of all numbers. For each number, determine the required suffix (or prefix) that would complete the target when concatenated, and use the map to count matching numbers in O(1) per lookup.

4. Handle edge cases

Consider cases where the target is shorter than some numbers, where concatenation could produce leading zeros (e.g., numbers like 0), and ensure that the same index can be used twice if the number appears multiple times.

5. Analyze complexity and test

State time complexity O(n * L) where L is the average length of numbers, and space O(n). Walk through a small example to verify the logic, including duplicates and self-pairing.

Key Points to Mention

  • Hash map for O(1) lookups to reduce time complexity from O(n^2) to O(n * L).
  • String manipulation: splitting the target string based on the length of the current number's string.
  • Handling leading zeros: numbers like 0 or 10 can cause ambiguity; ensure string conversion is correct.
  • Ordered pairs: (i, j) and (j, i) are distinct unless i = j, and i = j is allowed.
  • Edge cases: target shorter than number, empty list, target not achievable.
  • Complexity analysis: time O(n * L), space O(n), where L is the maximum length of a number's string.

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