497.Print a Rectangle Star Pattern
Easy
Given two integers
rows and cols, return a rectangle of stars — rows rows, each cols stars wide.
This is the Square Star Pattern problem generalized to independent row and column counts. Both solutions carry over directly: the nested loopsNested LoopsAn outer loop over rows, an inner loop appending one character at a time to build each row. version just uses cols instead of n for the inner bound, and the string repetitionString RepetitionBuilding the repeated row once with a built-in, then repeating that row rows times. version builds the cols-wide row once and repeats it rows times.
Example 1:
Input: rows = 2, cols = 4
Output: ["****","****"]
Example 2:
Input: rows = 1, cols = 1
Output: ["*"]
+ 2 hidden test cases run on Submit.
Constraints:
- ●
1 ≤ rows ≤ 20 - ●
1 ≤ cols ≤ 20
rows =
2
cols =
4