← Capital One Interview Insights

Capital One·Machine Learning Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Capital One ML Engineer interview with a coding question that was pretty light on the ML side. Just a basic string manipulation problem, nothing that really tested modeling knowledge.

Questions Asked (1)

Q1

Given a width, height, and optional fill character, write a function that prints a rectangular picture frame as a multi-line string, with border characters forming the rectangle and the interior either blank or filled.

Algorithms & Data Structures
Author's notes

Pretty basic loop problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify edge cases (zero/negative dimensions, fill character length) and define the output format. Build the frame row by row: top/bottom borders, middle rows with side borders and optional fill, then join with newlines. Test with small dimensions and no fill character.

Pro tip: Mention that you'd handle edge cases like width or height <= 0 by returning an empty string, and that the fill character should be exactly one character (or take the first if longer). This shows attention to detail and robustness.

1. Clarify requirements and edge cases

Ask about dimensions (positive integers?), fill character (single char? default?), and behavior for invalid inputs. Confirm output format (multi-line string).

2. Handle trivial cases

If width or height <= 0, return empty string. If height == 1, return a single row of border characters. If width == 1, return a column of border characters.

3. Construct top and bottom borders

Create a string of width border characters (e.g., '*') for the first and last rows.

4. Construct middle rows

For each interior row, create a string: border char + (fill char repeated width-2 times or spaces if no fill) + border char.

5. Assemble and return

Join all rows with newline characters and return the resulting string. Test with sample inputs.

Key Points to Mention

  • Edge cases: width/height <= 0, height=1, width=1, fill character length > 1
  • Default fill character: use space if not provided
  • Time and space complexity: O(width * height) time, O(width * height) space for output
  • String building efficiency: use list of strings and join, or StringBuilder in Java
  • Modularity: separate functions for border and middle rows for clarity
  • Testing: include examples like width=3, height=3, fill='*' and width=5, height=4, no fill

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