DEV Community

Cover image for Capital One OA Experience – 4 CodeSignal Questions in 70 Minutes
interviewshow-cs
interviewshow-cs

Posted on

Capital One OA Experience – 4 CodeSignal Questions in 70 Minutes

Capital One's Online Assessment was hosted on CodeSignal: four coding questions in 70 minutes.

My actual timing was:

  • Q1: 9 minutes
  • Q2: 11 minutes
  • Q3: 17 minutes
  • Q4: 25 minutes
  • Final review: about 8 minutes

Q4 was the closest one to going wrong. I initially submitted a brute-force solution, then realized the input size required a more efficient approach and rewrote it using a dictionary-based interval technique.

That was probably the biggest lesson from this OA: when you see an interval coverage problem, look at the constraints first and think about the optimized approach before submitting a brute-force solution.

Q1: Good Tuples

Given an array a, count how many consecutive triples (a[i-1], a[i], a[i+1]) are "good tuples."

A tuple is considered good when exactly two of its three values are equal.

  • All three values equal → not valid
  • All three values different → not valid
  • Exactly two values equal → valid

For example:

[1, 1, 1, 2, 1, 3, 4]

The tuple (1,1,1) does not count because all three values are the same. The tuples (1,1,2) and (1,2,1) are good tuples.

The easiest solution is to scan the array and count how many equal pairs exist inside each triple:

def goodTuples(a):
    count = 0

    for i in range(1, len(a) - 1):
        equal_pairs = (
            (a[i - 1] == a[i])
            + (a[i] == a[i + 1])
            + (a[i - 1] == a[i + 1])
        )

        if equal_pairs == 1:
            count += 1

    return count

If exactly one of the three comparisons is true, then exactly one pair matches, which means the tuple contains exactly two equal values.

Time complexity: O(n)

One easy mistake is the loop range. Since every tuple needs both a previous and next element, iterate from index 1 to len(a) - 2.

Q2: Absolute Difference Sums After Circular Shifts

You are given two arrays of equal length, nums1 and nums2.

Perform every possible circular right shift on nums1. For each shifted version, calculate the sum of absolute differences between corresponding elements in the two arrays. Return all results in sorted order.

Example:

nums1 = [1, 4, 2, 11]
nums2 = [10, 1, 8, 4]

The sums for shifts 0, 1, 2, and 3 are:

25, 7, 25, 13

After sorting:

[7, 13, 25, 25]

A direct simulation works well:

def absoluteDifferenceSum(nums1, nums2):
    n = len(nums1)
    results = []

    for shift in range(n):
        total = sum(
            abs(nums1[(i - shift + n) % n] - nums2[i])
            for i in range(n)
        )
        results.append(total)

    return sorted(results)

The most common mistake here is getting the shift direction wrong.

For a right shift:

[a, b, c] → [c, a, b]

Therefore, the value at position i in the new array comes from:

(i - shift + n) % n

It is worth manually checking the formula with a three-element array before submitting.

Q3: Two-Sum Queries with Updates

You are given arrays a and b, along with several queries:

  • [0, i, x]: update a[i] to x
  • [1, x]: count the number of pairs (i, j) such that a[i] + b[j] = x

Queries must be processed in order, and the results of all type-1 queries should be returned.

The key observation is that array b never changes.

Because of that, we can build a frequency map for b once. For every query, iterate through a and check how many matching values exist in b.

from collections import Counter

def solve(a, b, queries):
    b_freq = Counter(b)
    results = []

    for query in queries:
        if query[0] == 0:
            a[query[1]] = query[2]
        else:
            target = query[1]

            count = sum(
                b_freq.get(target - value, 0)
                for value in a
            )

            results.append(count)

    return results

A few easy mistakes:

  • Build Counter(b) only once. Do not rebuild it for every query.
  • Use get(key, 0) so missing values do not cause errors.
  • Do not remove duplicates from a. Every occurrence represents a separate valid pair.

Q4: Interval Coverage and Counting Unique Points

You are given a list of rays. Each ray is represented as:

[starting_angle, number_of_rotations]

A ray starts at its given angle and covers additional positions every 360 degrees. The goal is to count the total number of unique angle points covered by all rays.

My first attempt was brute force:

# Too slow for large inputs
covered = set()

for start, rotations in rays:
    for r in range(rotations + 1):
        covered.add(start + r * 360)

This passed some smaller test cases but timed out when the input became larger.

The optimized approach is to treat each ray as an interval:

[start, start + rotations × 360]

Then use a difference map and sweep through the interval events:

def raysCoverage(rays):
    from collections import defaultdict

    events = defaultdict(int)

    for start, rotations in rays:
        end = start + rotations * 360

        events[start] += 1
        events[end + 1] -= 1

    total = 0
    active = 0
    last_pos = None

    for pos in sorted(events.keys()):
        if last_pos is not None and active > 0:
            total += pos - last_pos

        active += events[pos]
        last_pos = pos

    return total

The +1 in:

events[end + 1] -= 1

is important because the endpoint itself is included in the interval. The coverage stops at the position after end.

Another important detail is that the event positions must be processed in sorted order.

Final Thoughts

The biggest lesson from this Capital One OA was definitely Q4.

Do not submit a brute-force solution first and hope the constraints are small enough. For interval coverage problems, check the input size immediately and decide whether you need a difference array, sweep line, or hash-based optimization before writing the first submission.

I finished the first three questions in about 37 minutes, which left enough time for Q4 and the final review. That pacing worked well.

One advantage of CodeSignal is that you can solve the questions in any order. I would recommend spending the first minute or two scanning all four problems, identifying the easiest ones, and securing those points first.

The Capital One OA also felt very similar to the broader CodeSignal-style question pool used by companies such as TikTok, Uber, and HRT. There is a significant amount of overlap in common problem patterns, so preparing for one of these companies can also help with several others.

If you're preparing for Capital One or other companies using CodeSignal, InterviewShow has organized common CodeSignal problem patterns and high-frequency question types into targeted preparation lists based on different companies. Feel free to reach out if you need a more focused practice plan.

Top comments (0)