Unique character string

https://ide.codingblocks.com/s/298141 why few test case is failing for this code