Foundations Loops through pattern printing
18. Increasing Letter Triangle
Easy
Given an integer n, return the pattern below as a list of strings, one string per row, top row first.
A
AB
ABC
ABCD
ABCDE
The pattern has n rows; the picture shows n = 5. Row i, counting from 1, holds the first i capital
letters of the English alphabet in order, side by side with nothing between them. No row has a space at
either end.
Example 1
Input: n = 4
Output:
A AB ABC ABCD
Example 2
Input: n = 1
Output:
AExample 3
Input: n = 26
Output:
A AB ABC ABCD ABCDE ABCDEF ABCDEFG ABCDEFGH ABCDEFGHI ABCDEFGHIJ ABCDEFGHIJK ABCDEFGHIJKL ABCDEFGHIJKLM ABCDEFGHIJKLMN ABCDEFGHIJKLMNO ABCDEFGHIJKLMNOP ABCDEFGHIJKLMNOPQ ABCDEFGHIJKLMNOPQR ABCDEFGHIJKLMNOPQRS ABCDEFGHIJKLMNOPQRST ABCDEFGHIJKLMNOPQRSTU ABCDEFGHIJKLMNOPQRSTUV ABCDEFGHIJKLMNOPQRSTUVW ABCDEFGHIJKLMNOPQRSTUVWX ABCDEFGHIJKLMNOPQRSTUVWXY ABCDEFGHIJKLMNOPQRSTUVWXYZ
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.