Company: IBM
Difficulty: medium
Question 2 Given a string, find the sum of the alphabetic weight of all substrings of the string that are palindromic. Return the answer modulo (10^9 + 7). For each palindromic substring, its weight is the sum of its characters' positions in the alphabet, i.e., 'a' = 1, 'b' = 2, ..., 'z' = 26. Note: A palindrome is a string that reads the same from the first character to the last and from the last character to the first. Example 1 Input: s = "abcbd" Output: 19 Explanation: Sum of Weights of all Palindromic Substrings Palindromic Substring Sum of Alphabetical Weights a 1 b 2 c 3