← Capital One Interview Insights

Capital One·Software Engineer·Online Assessment (OA)·Intermediate

IntermediateRejected
Aug 2026Remote

Summary

Took the General Assessment for a Front End Engineer role at Capital One through CodeSignal and didn't pass. Sharing the questions anyway because memorizing them felt like the least I could do after the rejection.

Questions Asked (4)

Q1

Write a function that takes an array of integers and returns a count of how many values are divisible by 3 and contain the digit 7 at least twice.

Algorithms & Data Structures
Author's notes

Pretty approachable.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First clarify edge cases and constraints, then outline a solution that iterates through the array, checks divisibility by 3, and counts digit occurrences of 7. Write clean code with helper functions and test with examples.

Pro tip: Mention that you can optimize by checking divisibility first (cheap operation) before counting digits, and use arithmetic digit extraction to avoid string conversion overhead.

1. Clarify requirements and edge cases

Ask about input size, negative numbers, zero, and whether 'contains the digit 7 at least twice' means exactly two or at least two occurrences. Confirm return type and handling of non-integers.

2. Outline approach and complexity

Explain that you'll iterate through each number, check if divisible by 3, then count digit 7s. State time complexity O(n * d) where d is average digits, and space O(1).

3. Implement digit counting

Write a helper function that counts occurrences of digit 7 using modulo and division, handling negative numbers by taking absolute value. Alternatively, convert to string and count.

4. Combine and count

Loop through the array, for each number check if divisible by 3 and if digit count >= 2, increment a counter. Return the counter.

5. Test and verify

Walk through test cases: empty array, numbers with multiple 7s but not divisible by 3, numbers divisible by 3 but fewer than two 7s, negative numbers, and zero.

Key Points to Mention

  • Edge cases: negative numbers, zero, empty array, and numbers with leading zeros (if string conversion).
  • Time and space complexity analysis.
  • Choice between arithmetic digit extraction and string conversion, with trade-offs.
  • Modular code with helper functions for readability and testability.
  • Handling of negative numbers by using absolute value before digit counting.
  • Verification with concrete examples and potential unit tests.

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

Q2

Simulate a two-player card game where each round the top card from each player's deck determines the winner. Return the total number of rounds played when one deck runs out.

Algorithms & Data Structures
Author's notes

Queue simulation, nothing more.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the rules and edge cases first, then propose a simulation using queues or two pointers to compare top cards each round. Discuss time and space complexity, and consider optimizations like early termination or cycle detection if decks can be infinite.

Pro tip: Mention that you would handle infinite loops by detecting repeated deck states, showing awareness of potential pitfalls beyond the basic simulation.

1. Clarify the problem

Ask about deck sizes, card values, tie-breaking rules, and whether decks can be infinite or cycle. Confirm that the game ends when one deck is empty.

2. Choose data structures

Use queues (or deques) to represent each player's deck, allowing O(1) removal from the top and addition to the bottom. Alternatively, use two pointers if decks are arrays and we only need to track positions.

3. Simulate rounds

While both decks are non-empty, compare the top cards. The winner takes both cards and places them at the bottom of their deck. Increment the round counter.

4. Handle termination and edge cases

Return the round count when one deck is empty. If infinite loops are possible, detect cycles by storing seen deck states or limit rounds.

5. Analyze complexity

Time complexity is O(R) where R is the number of rounds, and space is O(N) for the queues. Discuss potential optimizations if needed.

Key Points to Mention

  • Use of queues or two pointers for efficient card manipulation
  • Tie-breaking rules and how they affect the game outcome
  • Cycle detection to prevent infinite loops when decks can repeat
  • Time and space complexity analysis
  • Edge cases: empty decks initially, one deck much larger than the other
  • Potential optimizations like early termination if one deck is guaranteed to win

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

Q3

Given a matrix, partition it into four submatrices by choosing one row index and one column index as the split points. Each partition must contain at least one non-negative cell. The average of a partition is the sum of its non-negative values divided by the count of non-negative values, floored. Return the row and column indices that minimize the difference between the highest and lowest partition average.

Algorithms & Data Structures
Author's notes

This one is where I probably lost the most time.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints and edge cases first, then propose an efficient algorithm that precomputes prefix sums and counts of non-negative values to evaluate all possible split points in O(R*C) time. Discuss how to handle partitions with no non-negative cells and how to compute floored averages, then compare candidate splits to find the minimum difference.

Pro tip: Mention that you would validate the solution with brute force on small random matrices to catch off-by-one errors in partition boundaries, and discuss time/space complexity trade-offs to show engineering maturity.

1. Clarify requirements and edge cases

Ask about matrix dimensions, value ranges, and what to do if a partition has no non-negative cells (e.g., skip that split or treat average as 0). Confirm that split indices are 0-based and that partitions are non-empty.

2. Design efficient computation

Use 2D prefix sums for non-negative values and counts to compute the sum and count for any submatrix in O(1). This allows evaluating all O(R*C) split points efficiently.

3. Compute partition averages

For each candidate split (r, c), compute the four partition averages as floor(sum / count) for non-negative cells. If any partition has count 0, skip that split.

4. Find optimal split

Track the minimum difference between the maximum and minimum partition averages across all valid splits. Return the row and column indices of the best split.

5. Analyze complexity and test

State time complexity O(R*C) and space O(R*C) for prefix arrays. Suggest testing with small random matrices against a brute-force implementation to verify correctness.

Key Points to Mention

  • 2D prefix sums for both sum and count of non-negative values
  • Handling partitions with zero non-negative cells (skip or define average)
  • Floor division for average calculation
  • Time and space complexity analysis (O(R*C) time, O(R*C) space)
  • Edge cases: 1x1 matrix, all negative values, splits at boundaries
  • Validation via brute-force on small inputs

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

Q4

You are given a 2D array of lamps, where each lamp covers a segment on a number line defined by a start and end point. Given an array of control points, return an array where each element is the count of lamps whose segment includes that control point.

Algorithms & Data Structures
Author's notes

Marked hard and I'd agree.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a difference array to efficiently mark the start and end of each lamp's coverage, then compute prefix sums to get coverage counts at all points. For each control point, look up the count in O(1) time. This handles large inputs well and avoids checking each lamp for each point.

Pro tip: Clarify whether the segments are inclusive of endpoints and whether control points can be outside the range of all lamps; handle these edge cases explicitly. Also, mention that if the number of control points is small, a brute-force approach might be acceptable, but the difference array solution scales better.

1. Understand the problem and constraints

Confirm the meaning of 'includes' (inclusive/exclusive endpoints), the range of coordinates, and the number of lamps and control points. Ask about potential duplicates or unsorted input.

2. Choose an efficient algorithm

Decide between brute-force (O(L*Q)) and difference array with prefix sums (O(L + Q + R)), where R is the coordinate range. Explain why the latter is better for large inputs.

3. Implement the difference array

Create an array of size max_coordinate+2 (or use a hash map for sparse coordinates). For each lamp [start, end], increment diff[start] and decrement diff[end+1] (if inclusive).

4. Compute prefix sums and answer queries

Compute the running sum over the difference array to get coverage counts at each point. For each control point, return the count from the prefix sum array (or 0 if out of range).

5. Test and handle edge cases

Test with overlapping lamps, points at boundaries, points outside all segments, and large coordinate values. Discuss time and space complexity.

Key Points to Mention

  • Difference array technique for range updates
  • Prefix sum for point queries
  • Time complexity: O(L + Q + R) vs O(L*Q) brute force
  • Space complexity: O(R) or O(L) with coordinate compression
  • Handling inclusive/exclusive endpoints
  • Edge cases: points outside all segments, overlapping segments, large coordinates

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