All Tracks Algorithms Dynamic Programming 2 Dimensional Problem

Palindrome Count
Tag(s):

Basic Programming, Easy, Two dimensional

Problem
Editorial
Analytics

Given a string S, count the number of non empty sub strings that are palindromes.
A sub string is any continuous sequence of characters in the string.
A string is said to be palindrome, if the reverse of the string is same as itself.
Two sub strings are different if they occur at different positions in S

Input
Input contains only a single line that contains string S.

Output
Print a single number, the number of sub strings that are palindromes.

Constraints
1 <= |S| <= 50
S contains only lower case latin letters, that is characters a to z.

SAMPLE INPUT
dskjkd
SAMPLE OUTPUT
7
Explanation

The 7 sub strings are d, s, k, j, k, d, kjk.

Time Limit: 3,0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

Practice Placement Challenge - 1

OTHER PROBLEMS OF THIS CHALLENGE
Уведомления
View All Notifications

?