Foundations Loops through pattern printing
19. Reverse Letter Triangle
Easy
Given an integer n, return the pattern below as a list of strings, one string per row, top row first.
ABCD
ABC
AB
A
The picture shows n = 4. The top row holds the first n capital letters of the alphabet in order. Each row
below it loses its last letter, so the bottom row is just A. Every row starts with A at the left edge.
The letters in a row sit side by side, with no spaces between them and none at either end.
Example 1
Input: n = 4
Output:
ABCD ABC AB A
Example 2
Input: n = 1
Output:
AExample 3
Input: n = 26
Output:
ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXY ABCDEFGHIJKLMNOPQRSTUVWX ABCDEFGHIJKLMNOPQRSTUVW ABCDEFGHIJKLMNOPQRSTUV ABCDEFGHIJKLMNOPQRSTU ABCDEFGHIJKLMNOPQRST ABCDEFGHIJKLMNOPQRS ABCDEFGHIJKLMNOPQR ABCDEFGHIJKLMNOPQ ABCDEFGHIJKLMNOP ABCDEFGHIJKLMNO ABCDEFGHIJKLMN ABCDEFGHIJKLM ABCDEFGHIJKL ABCDEFGHIJK ABCDEFGHIJ ABCDEFGHI ABCDEFGH ABCDEFG ABCDEF ABCDE ABCD ABC AB A
Check your understanding
Work out the answer for this input before you write any code.
n = 3
Constraints
1 ≤ n ≤ 26
Clarifying questions
What you would ask an interviewer before writing any code.