← Capital One Interview Insights

Capital One·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Capital One technical screen, one coding problem that looked simple on the surface but had enough edge cases to trip you up if you weren't careful. Nothing crazy, just needed to think it through properly.

Questions Asked (1)

Q1

Given a string, if both the first and last characters are vowels (case-insensitive), reverse the substring between them (excluding the endpoints) and return the result. Otherwise return the string as-is. Expected O(n) time with a two-pointer approach, and you need to walk through edge cases like empty strings, single characters, two characters, and mixed case.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The reversal itself is not the hard part.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the problem and edge cases, then explain a two-pointer solution that checks the first and last characters for vowels (case-insensitive) and reverses the middle substring in O(n) time. Walk through examples and edge cases to demonstrate correctness and efficiency.

Pro tip: Mention that you can reverse the middle substring in-place by swapping characters from both ends moving inward, which avoids extra space and keeps the solution O(n) time and O(1) space (if the string is mutable).

1. Clarify requirements and edge cases

Confirm that the string may be empty, have one or two characters, and that vowels are a, e, i, o, u (case-insensitive). Ask if the string is mutable or if a new string should be returned.

2. Check first and last characters

If the string length is less than 2, return it as-is. Otherwise, check if both the first and last characters are vowels (case-insensitive). If not, return the original string.

3. Reverse the middle substring

Use two pointers starting at index 1 and index n-2, swapping characters and moving inward until they meet or cross. This reverses the substring between the endpoints in O(n) time.

4. Return the result

After the reversal, return the modified string (or the original if no reversal was needed).

5. Test with examples and edge cases

Walk through examples like 'abc' (no change), 'aeb' (reverse 'e' -> 'aeb'? actually 'aeb' becomes 'aeb'? Wait, 'aeb': first 'a' vowel, last 'b' not vowel -> no change), 'aeiou' (first 'a' and last 'u' vowels, reverse 'eio' -> 'a o i e u'? Actually 'aeiou' -> reverse middle 'eio' -> 'a o i e u' = 'aoieu'), empty string, single char, two chars, and mixed case like 'Aeb' (first 'A' vowel, last 'b' not vowel -> no change) or 'AeB' (first 'A' vowel, last 'B' not vowel -> no change). Also test 'AeA' (first 'A' vowel, last 'A' vowel, reverse middle 'e' -> 'AeA' unchanged).

Key Points to Mention

  • Case-insensitive vowel check (e.g., convert to lowercase or use a set of vowels).
  • Two-pointer technique for in-place reversal of the middle substring.
  • Time complexity O(n) and space complexity O(1) if in-place, or O(n) if creating a new string.
  • Edge cases: empty string, single character, two characters, no vowels at ends, all vowels, mixed case.
  • Handling of non-alphabetic characters (if any) — clarify if they are considered non-vowels.
  • Trade-offs: in-place reversal vs. creating a new string (immutability in languages like Java/Python).

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