← Capital One Interview Insights

Capital One·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Went through a coding screen for a Software Engineer role at Capital One. Just one question from what I can tell, string manipulation stuff, nothing too wild but worth thinking through carefully.

Questions Asked (1)

Q1

Given a string, find and return the longest substring made up entirely of the same repeated character.

Algorithms & Data Structures
Author's notes

Pretty classic sliding window type problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem and edge cases, then propose a single-pass linear scan that tracks the current run of identical characters and the best run seen so far. Walk through the algorithm with a small example, state the O(n) time and O(1) space complexity, and offer to code it cleanly with tests.

Pro tip: Mention that you'd return the substring itself, not just its length, and handle empty or single-character inputs gracefully. Also note that if the interviewer only wants the length, the same scan works with a minor tweak, showing you can adapt to changing requirements.

1. Clarify requirements and edge cases

Ask whether to return the substring or its length, and confirm handling of empty strings, single characters, and ties (e.g., return the first longest run).

2. Outline the linear scan approach

Explain that you'll iterate through the string once, maintaining the start and length of the current run of identical characters and the best run found so far.

3. Walk through an example

Trace the algorithm on a sample input like 'aabbbcc' to show how the current run resets when the character changes and how the best run is updated.

4. State complexity and trade-offs

Highlight O(n) time and O(1) extra space, and mention that a brute-force approach would be O(n^2) or O(n^3), making this optimal.

5. Code and test

Write clean code with meaningful variable names, then test with edge cases (empty string, all same characters, alternating characters) to verify correctness.

Key Points to Mention

  • Single-pass linear scan with O(n) time and O(1) space
  • Tracking current run start/length and best run start/length
  • Handling edge cases: empty string, single character, all identical characters
  • Returning the substring (or length) as specified, and tie-breaking by first occurrence
  • Comparing with brute-force alternatives and explaining why the linear scan is optimal
  • Writing clean, readable code and testing with examples

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