Math, asked by dikshapalak2272, 1 year ago

Queen of westeros is known for her dragons and magic. To control her dragons she speaks random but powerful words. The strength of her words can be predicted by a strange rule. Rule : strength of a word is sum of square of size of palindromic substrings in the word. To recall the definition of palindrome, palindrome is a word which reads same when read forward and backward. For example, word "abaa" has 6 palindromic substrings. "aba","aa","a","b","a","a" with sizes 3,2,1,1,1,1 respectively. Their squares are 9,4,1,1,1,1. Hence total strength is 17. Given a queens word ind its strength.

Answers

Answered by amitnrw
0

let say word queen speak

LEVEL

palindrome here

LEVEL - 5

EVE - 3

L - 1

E - 1

V - 1

E - 1

L - 1

5^2 = 25

3^2 = 9

1^2 = 1

sum = 25 + 9 + 1 + 1 + 1 + 1 + 1 = 39

strength of Level = 39

Similar questions