Count how many substrings start and end with the same character (simple logic).: Hard Programming Problem