PPractick

DSA interview question

Pattern 19: Symmetric Void

Easy · Algorithms · Topics: pattern building

The problem

The symmetric void is a rectangle of stars with a diamond-shaped hole in the middle. The top half starts with a full row of stars, and a gap opens in the centre that widens by two each row. The bottom half closes it again. Each row has three segments (stars, gap, stars), and the challenge is writing the formulas for all three in both halves without off-by-one errors.

Example for n = 5:

**********
****  ****
***    ***
**      **
*        *
*        *
**      **
***    ***
****  ****
**********

Function signature

vector<string> symmetricVoid(int n);  // 2n rows, each 2n characters wide

Test cases

Input nOutput rowsExplanation
1"**", "**"Each half is one full row with no gap
2"****", "* *", "* *", "****"Gap of 2 in the middle rows
3"******", "** **", "* *", "* *", "** **", "******"Gap widens 0, 2, 4, then closes
5as in the exampleEvery row is 2n = 10 characters

(Confirm: 2n rows, with the widest gap appearing twice. Every row is exactly 2n characters and ends with a star, so there are no trailing spaces.)

How interviewers phrase it

Clarifying questions to ask

  1. Is N the number of rows in each half?
  2. Should the middle row repeat (2n rows)?
  3. Print or return?

Follow-ups to expect

  1. "What are the segment lengths in the top half?"
  2. "And the bottom half?"
  3. "How is this related to Pattern 20?"
  4. "Complexity?"

Practise questions like this with a real engineer

On Practick another engineer interviews you live for 60 minutes on a question from this bank. They have the full interviewer guide beside the call: the expected answer to every follow-up, hints to give if you stall, and a scoring rubric. You get the model solution once the session settles. It is free: interview someone for an hour and you have earned your own.

Book a free mock interview

Related questions

All 474 dsa interview questions

DSA mock interviews · System design interview questions · Free mock interview practice · Browse interviewers · Sign in