Added linear running time solution for balanced smileys