
A substring is a string formed after deleting zero or more characters from both ends of a string.
Input:
S = “hello"
Output:
5
Explanation: The following substring ‘hell’, ‘ell’, ‘llo’, ‘ello’, and ‘hello’ has the beauty of 1. Hence we return 5.
The first line of the input will contain an integer ‘N’ denoting the length of the string ‘S’.
The next line contains the string ’S’.
Output is printed on a separate line.
You don’t need to print anything. Just implement the given function.
Algorithm:
Function int sumOfBeauty(string S):