Sherlock And The Valid String Java Solution