Company: IBM

Difficulty: medium

Problem Statement

Given a string, find the sum of the alphabetic weight of all substrings of the string that are palindromes. 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

More IBM OA questionsInterview experiences