Problem Statement | |||||||||||||
The distance between two strings with respect to a letter is defined as (n1 - n2)2, where n1 and n2 are the number of occurrences (both lowercase and uppercase) of that letter in the first and second strings, respectively. The distance between two strings with respect to a third string is the sum of the distances between the two strings with respect to each letter in the third string. You will be given three Strings a, b and letterSet. All the letters in letterSet will be distinct. Return the distance between a and b with respect to letterSet. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | a will contain between 1 and 50 characters, inclusive. | ||||||||||||
- | a will contain only letters ('a'-'z', 'A'-'Z'). | ||||||||||||
- | b will contain between 1 and 50 characters, inclusive. | ||||||||||||
- | b will contain only letters ('a'-'z', 'A'-'Z'). | ||||||||||||
- | letterSet will contain between 1 and 26 characters, inclusive. | ||||||||||||
- | letterSet will contain only lowercase letters ('a'-'z'). | ||||||||||||
- | Each character in letterSet will be distinct. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
| |||||||||||||
5) | |||||||||||||
|