PPractick

DSA interview question

Pattern 15: Reverse Letter Triangle

Easy · Algorithms · Topics: pattern building

The problem

This is the letter version of the inverted triangle: the first row holds the first n letters of the alphabet, and every row after it drops the last letter, until only A remains. It combines the shrinking row length from Pattern 5 with the character arithmetic from Pattern 14, so it's a quick check that you can mix a shape rule with a value rule without mixing them up.

Example for n = 5:

ABCDE
ABCD
ABC
AB
A

Function signature

vector<string> reverseLetterTriangle(int n);  // row i: the first n - i + 1 letters

Test cases

Input nOutput rowsExplanation
1"A"
3"ABC", "AB", "A"Each row drops its last letter
5"ABCDE", "ABCD", "ABC", "AB", "A"

(Confirm: 1 ≤ n ≤ 26; letters without separators.)

How interviewers phrase it

Clarifying questions to ask

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

Follow-ups to expect

  1. "What controls the row length?"
  2. "What controls the letters?"
  3. "How would each row end on the same letter instead?"
  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