@@ -0,0 +1,1577 @@
+// https://community.topcoder.com/stat?c=problem_statement&pm=12275%0A%0Aimport java.util.Map;%0Aimport java.util.HashMap;%0A%0Apublic class ValueHistogram %7B%0A%09public static String%5B%5D build(int%5B%5D values) %7B%0A%09%09// Get frequency of each character & max frequency%0A%09%09Map%3CInteger, Integer%3E valueFrequencies = new HashMap%3CInteger, Integer%3E();%0A%09%09int maxFrequencies = 0;%0A%09%09%0A%09%09for (int value : values) %7B%0A%09%09%09int frequencyCount = valueFrequencies.containsKey(value) ? valueFrequencies.get(value) : 0;%0A%09%09%09valueFrequencies.put(value, frequencyCount + 1);%0A%09%09%09%0A%09%09%09if (valueFrequencies.get(value) %3E maxFrequencies) %7B%0A%09%09%09%09maxFrequencies = valueFrequencies.get(value);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09// Generate histogram%0A%09%09final int HISTOGRAM_WIDTH = 10; // number of columns (number of characters on each row)%0A%09%09final int HISTOGRAM_HEIGHT = maxFrequencies + 1; // number of rows%0A%09%09char%5B%5D%5B%5D histogramMatrix = new char%5BHISTOGRAM_HEIGHT%5D%5BHISTOGRAM_WIDTH%5D;%0A%09%09%0A%09%09for (int colIndex = 0; colIndex %3C HISTOGRAM_WIDTH; ++colIndex) %7B%0A%09%09%09int currentFrequencies = valueFrequencies.containsKey(colIndex) ? valueFrequencies.get(colIndex) : 0;%0A%09%09%09%0A%09%09%09for (int rowIndex = HISTOGRAM_HEIGHT - 1; rowIndex %3E= 0; --rowIndex) %7B%0A%09%09%09%09if (currentFrequencies %3E 0) %7B%0A%09%09%09%09%09histogramMatrix%5BrowIndex%5D%5BcolIndex%5D = 'X';%0A%09%09%09%09%09currentFrequencies--;%0A%09%09%09%09%7D%0A%09%09%09%09else %7B%0A%09%09%09%09%09histogramMatrix%5BrowIndex%5D%5BcolIndex%5D = '.';%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09// Convert 2D char array to String array%0A%09%09String%5B%5D histogram = new String%5BHISTOGRAM_HEIGHT%5D;%0A%09%09for (int i = 0; i %3C histogram.length; ++i) %7B%0A%09%09%09histogram%5Bi%5D = new String(histogramMatrix%5Bi%5D);%0A%09%09%7D%0A %09%09%0A%09%09return histogram;%0A%09%7D%0A%7D%0A

Create ValueHistogram.java