uniqueChars solution without extra data structures