PPractick

DSA interview question

Pattern 18: Alpha Triangle

Easy · Algorithms · Topics: pattern building

The problem

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

Function signature

vector<string> alphaTriangle(int n);  // row i: letters from the (n - i + 1)-th to the n-th

Test cases

Input nOutput rowsExplanation
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.)

How interviewers phrase it

Clarifying questions to ask

  1. N at most 26?
  2. Separators between letters?
  3. Print or return?

Follow-ups to expect

  1. "What's the first letter of row i?"
  2. "How is this different from Pattern 15?"
  3. "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