DSA interview question
In this triangle every row ends on the same letter, the n-th letter of the alphabet, and each row starts one letter earlier than the one above it. For n = 5, the rows are E, DE, CDE, BCDE, ABCDE. Compared with Pattern 15, which always starts at A and stops earlier, this one always stops at the same letter and starts earlier. That's a useful twist because the starting letter has to be computed from both n and the row.
Example for n = 5:
E
DE
CDE
BCDE
ABCDE
vector<string> alphaTriangle(int n); // row i: letters from the (n - i + 1)-th to the n-th
Input n | Output rows | Explanation |
|---|---|---|
| 1 | "A" | The 1st letter is A |
| 3 | "C", "BC", "ABC" | Every row ends in C |
| 5 | "E", "DE", "CDE", "BCDE", "ABCDE" | Every row ends in E |
(Confirm: 1 ≤ n ≤ 26; letters without separators.)
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