String histogram without using HashMap