Foundations Loops through pattern printing
20. Letter Ramp
Easy
Given an integer n, return the pattern below as a list of strings, one string per row, top row first.
A
BB
CCC
DDDD
The picture shows n = 4. Counting rows from 1 at the top, row i holds one letter only: the i-th capital
letter of the alphabet, written i times. So row 1 is a single A, row 2 is BB, and the last row holds the
n-th letter n times.
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:
A BB CCC DDDD
Example 2
Input: n = 1
Output:
AExample 3
Input: n = 26
Output:
A BB CCC DDDD EEEEE FFFFFF GGGGGGG HHHHHHHH IIIIIIIII JJJJJJJJJJ KKKKKKKKKKK LLLLLLLLLLLL MMMMMMMMMMMMM NNNNNNNNNNNNNN OOOOOOOOOOOOOOO PPPPPPPPPPPPPPPP QQQQQQQQQQQQQQQQQ RRRRRRRRRRRRRRRRRR SSSSSSSSSSSSSSSSSSS TTTTTTTTTTTTTTTTTTTT UUUUUUUUUUUUUUUUUUUUU VVVVVVVVVVVVVVVVVVVVVV WWWWWWWWWWWWWWWWWWWWWWW XXXXXXXXXXXXXXXXXXXXXXXX YYYYYYYYYYYYYYYYYYYYYYYYY ZZZZZZZZZZZZZZZZZZZZZZZZZZ
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.