Problem Statement | |||||||||||||
We call a string a square if it is a concatenation of two equal non-empty strings. All string comparisons in this problem are case sensitive. For example, "aa", "ABAB", and "abcabc" are squares, but "a", "aaa", "ABCabc", and "abcab" are not.
Given a String s, return the number of distinct squares that appear as contiguous substrings of s. For example, in "aaabccabccCC", you can find the squares "aa", "abccabcc", "cc", and "CC", so you would return 4. The squares "aa" and "cc" each appear twice in the string, but they're only counted once because we're only interested in distinct squares. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | s will contain between 0 and 50 characters, inclusive. | ||||||||||||
- | s will contain only letters ('a'-'z', 'A'-'Z'). | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|