DSA interview question
The alpha hill is a centred pyramid of letters where each row climbs from A up to the row's peak letter and back down: A, ABA, ABCBA. It reuses the star pyramid's spacing (n − i leading spaces, 2i − 1 characters) but fills the characters with a palindrome instead of stars. It's a nice test of whether you can combine a known shape with a new content rule, and of handling the "peak" character exactly once.
Example for n = 4:
A
ABA
ABCBA
ABCDCBA
vector<string> alphaHill(int n); // row i: n - i spaces, then A..(i-th letter)..A
Input n | Output rows | Explanation |
|---|---|---|
| 1 | "A" | |
| 2 | " A", "ABA" | |
| 3 | " A", " ABA", "ABCBA" | Peak letter appears once per row |
| 4 | as in the example | Row i has 2i − 1 letters |
(Confirm: 1 ≤ n ≤ 26; leading spaces for centring, no trailing spaces.)
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 interviewAll 474 dsa interview questions
DSA mock interviews · System design interview questions · Free mock interview practice · Browse interviewers · Sign in