Print Vertical Asterisk Bars
Problem statement
Given an array of nonnegative bar heights, return a top-to-bottom text drawing of vertical bars.
Each output row contains exactly one character per input bar: * when that bar reaches the row and a space otherwise. Bars are bottom-aligned. Return an empty array when there are no positive heights.
Function
drawVerticalBars(heights: int[]) → String[]Examples
Example 1
heights = [3,1,2]return = ["* ","* *","***"]The first bar reaches all three rows, the second reaches only the bottom row, and the third reaches the bottom two rows.
Example 2
heights = [0,0]return = []No bar has positive height, so there are no rows to draw.
Constraints
0 <= heights.length <= 10000 <= heights[i] <= 1000