String count palindromic

https://hack.codingblocks.com/contests/c/509/236
https://ide.codingblocks.com/#/s/29535
problem: showing wrong ans on submitting but ans is correct.

INPUT: abcd
OUTPUT: 6
EXPECTED OUTPUT: 4

You are asked to find number of substrings that are palindrome and not the total number of substrings.

1 Like

can u plz explain it by an example;
i don’t get it.

abba
palindromic substrings:
a
abba
b
bb
b
a
non palindromic substrings:
ab
abb
bba
ba
TOTAL: N*(N+1)/2 where N=4

1 Like

ok, thanks bhaiya…