From c8c5f36bfbd7e42888c44c88ebd4a29fb2f47bb7 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Wed, 18 Oct 2017 17:32:03 +0800 Subject: [PATCH] Add question 1 --- algorithms/array.md | 2 +- questions/01-histogram-stars.md | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 questions/01-histogram-stars.md diff --git a/algorithms/array.md b/algorithms/array.md index 4027cfaa..0de9fedc 100644 --- a/algorithms/array.md +++ b/algorithms/array.md @@ -7,7 +7,7 @@ Arrays - Paginate an array with constraints, such as skipping certain items. - Implement a circular buffer using an array. - Given array of arrays, sort them in ascending order. -- Given an array of integers, print out a histogram of using said array; include a base layer (all stars) +- Given an array of integers, print out a histogram using the said array; include a base layer (all stars) - E.g. `[5, 4, 0, 3, 4, 1]` ``` diff --git a/questions/01-histogram-stars.md b/questions/01-histogram-stars.md new file mode 100644 index 00000000..a0a6a448 --- /dev/null +++ b/questions/01-histogram-stars.md @@ -0,0 +1,35 @@ +--- +id: 1 +title: Histogram Stars +topics: [array] +difficulty: easy +--- + +## Question + +``` +''' +Given an array of integers, print out a histogram using the array. Include a base layer (all stars) + +[5, 4, 0, 3, 4, 1] will result in the following: + +****** +***** +* +**** +***** +** +''' +``` + +``` +Print out a vertical version of the histogram. + +* +** * +** ** +** ** +** *** +****** +''' +```